Skip to content

Commit

Permalink
Merge pull request #320 from hintjens/master
Browse files Browse the repository at this point in the history
Fix to #319
  • Loading branch information
c-rack committed May 2, 2015
2 parents d4234f3 + 463d2a6 commit a351468
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 90 deletions.
152 changes: 76 additions & 76 deletions api/zyre.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<class name="zyre">
<class name = "zyre">
An open-source framework for proximity-based P2P apps

<include filename = "../license.xml" />
Expand All @@ -8,57 +8,57 @@
node it is silent and invisible to other nodes on the network.
The node name is provided to other nodes during discovery. If you
specify NULL, Zyre generates a randomized node name from the UUID.
<argument name="name" type="string" />
<argument name = "name" type = "string" />
</constructor>

<destructor>
Destructor, destroys a Zyre node. When you destroy a node, any
messages it is sending or receiving will be discarded.
</destructor>

<method name="uuid">
<method name = "uuid">
Return our node UUID string, after successful initialization
<return type="string" />
<return type = "string" />
</method>

<method name="name">
<method name = "name">
Return our node name, after successful initialization
<return type="string" />
<return type = "string" />
</method>

<method name="set_header">
<method name = "set_header">
Set node header; these are provided to other nodes during discovery
and come in each ENTER message.
<argument name="name" type="string" />
<argument name="format" type="format" />
<argument name = "name" type = "string" />
<argument name = "format" type = "format" />
</method>

<method name="set_verbose">
<method name = "set_verbose">
Set verbose mode; this tells the node to log all traffic as well as
all major events.
</method>

<method name="set_port">
<method name = "set_port">
Set UDP beacon discovery port; defaults to 5670, this call overrides
that so you can create independent clusters on the same network, for
e.g. development vs. production. Has no effect after zyre_start().
<argument name="port_nbr" type="integer" />
<argument name = "port_nbr" type = "integer" />
</method>

<method name="set_interval">
<method name = "set_interval">
Set UDP beacon discovery interval, in milliseconds. Default is instant
beacon exploration followed by pinging every 1,000 msecs.
<argument name="interval" type="size" />
<argument name = "interval" type = "size" />
</method>

<method name="set_interface">
<method name = "set_interface">
Set network interface for UDP beacons. If you do not set this, CZMQ will
choose an interface for you. On boxes with several interfaces you should
specify which one you want to use, or strange things can happen.
<argument name="value" type="string" />
<argument name = "value" type = "string" />
</method>

<method name="set_endpoint">
<method name = "set_endpoint">
By default, Zyre binds to an ephemeral TCP port and broadcasts the local
host name using UDP beaconing. When you call this method, Zyre will use
gossip discovery instead of UDP beaconing. You MUST set-up the gossip
Expand All @@ -67,132 +67,132 @@
inproc://, ipc://, or tcp:// transports (for tcp://, use an IP address
that is meaningful to remote as well as local nodes). Returns 0 if
the bind was successful, else -1.
<argument name="format" type="format" />
<return type="integer" />
<argument name = "format" type = "format" />
<return type = "integer" />
</method>

<method name="gossip_bind">
<method name = "gossip_bind">
Set-up gossip discovery of other nodes. At least one node in the cluster
must bind to a well-known gossip endpoint, so other nodes can connect to
it. Note that gossip endpoints are completely distinct from Zyre node
endpoints, and should not overlap (they can use the same transport).
<argument name="format" type="format" />
<argument name = "format" type = "format" />
</method>

<method name="gossip_connect">
<method name = "gossip_connect">
Set-up gossip discovery of other nodes. A node may connect to multiple
other nodes, for redundancy paths. For details of the gossip network
design, see the CZMQ zgossip class.
<argument name="format" type="format" />
<argument name = "format" type = "format" />
</method>

<method name="start">
<method name = "start">
Start node, after setting header values. When you start a node it
begins discovery and connection. Returns 0 if OK, -1 if it wasn't
possible to start the node.
<return type="integer" />
<return type = "integer" />
</method>

<method name="stop">
<method name = "stop">
Stop node; this signals to other peers that this node will go away.
This is polite; however you can also just destroy the node without
stopping it.
</method>

<method name="join">
<method name = "join">
Join a named group; after joining a group you can send messages to
the group and all Zyre nodes in that group will receive them.
<argument name="group" type="string" />
<return type="integer" />
<argument name = "group" type = "string" />
<return type = "integer" />
</method>

<method name="leave">
<method name = "leave">
Leave a group
<argument name="group" type="string" />
<return type="integer" />
<argument name = "group" type = "string" />
<return type = "integer" />
</method>

<method name="recv">
<method name = "recv">
Receive next message from network; the message may be a control
message (ENTER, EXIT, JOIN, LEAVE) or data (WHISPER, SHOUT).
Returns zmsg_t object, or NULL if interrupted
<return type="zmsg" />
<return type = "zmsg" />
</method>

<method name="whisper">
<method name = "whisper">
Send message to single peer, specified as a UUID string
Destroys message after sending
<argument name="peer" type="string" />
<argument name="msg_p" type="zmsg" by_reference="1" />
<return type="integer" />
<argument name = "peer" type = "string" />
<argument name = "msg_p" type = "zmsg" by_reference = "1" />
<return type = "integer" />
</method>

<method name="shout">
<method name = "shout">
Send message to a named group
Destroys message after sending
<argument name="group" type="string" />
<argument name="msg_p" type="zmsg" by_reference="1" />
<return type="integer" />
<argument name = "group" type = "string" />
<argument name = "msg_p" type = "zmsg" by_reference = "1" />
<return type = "integer" />
</method>

<method name="whispers">
<method name = "whispers">
Send formatted string to a single peer specified as UUID string
<argument name="peer" type="string" />
<argument name="format" type="format" />
<return type="integer" />
<argument name = "peer" type = "string" />
<argument name = "format" type = "format" />
<return type = "integer" />
</method>

<method name="shouts">
<method name = "shouts">
Send formatted string to a named group
<argument name="group" type="string" />
<argument name="format" type="format" />
<return type="integer" />
<argument name = "group" type = "string" />
<argument name = "format" type = "format" />
<return type = "integer" />
</method>

<method name="peers">
Return zlist of current peer ids.
<return type="zlist" fresh="1" />
<method name = "peers">
Return zlist of current peer ids.
<return type = "zlist" fresh = "1" />
</method>

<method name="own_groups">
Return zlist of currently joined groups.
<return type="zlist" fresh="1" />
<method name = "own_groups">
Return zlist of currently joined groups.
<return type = "zlist" fresh = "1" />
</method>

<method name="peer_groups">
Return zlist of groups known through connected peers.
<return type="zlist" fresh="1" />
<method name = "peer_groups">
Return zlist of groups known through connected peers.
<return type = "zlist" fresh = "1" />
</method>

<method name="peer_address">
Return the endpoint of a connected peer.
<argument name="peer" type="string" />
<return type="string" fresh="1" />
<method name = "peer_address">
Return the endpoint of a connected peer.
<argument name = "peer" type = "string" />
<return type = "string" fresh = "1" />
</method>

<method name="peer_header_value">
<method name = "peer_header_value">
Return the value of a header of a conected peer.
Returns null if peer or key doesn't exist.
<argument name="peer" type="string" />
<argument name="name" type="string" />
<return type="string" fresh="1" />
Returns null if peer or key doesn't exits.
<argument name = "peer" type = "string" />
<argument name = "name" type = "string" />
<return type = "string" fresh = "1" />
</method>

<method name="socket">
<method name = "socket">
Return socket for talking to the Zyre node, for polling
<return type="zsock" />
<return type = "zsock" />
</method>

<method name="version" singleton="1">
<method name = "version" singleton = "1">
Return the Zyre version for run-time API detection
<argument name="major" type="integer" by_reference="1" />
<argument name="minor" type="integer" by_reference="1" />
<argument name="patch" type="integer" by_reference="1" />
<argument name = "major" type = "integer" by_reference = "1" />
<argument name = "minor" type = "integer" by_reference = "1" />
<argument name = "patch" type = "integer" by_reference = "1" />
</method>

<method name="test" singleton="1">
<method name = "test" singleton = "1">
Self test of this class
<argument name="verbose" type="boolean" />
<argument name = "verbose" type = "boolean" />
</method>

</class>
10 changes: 4 additions & 6 deletions src/zyre.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,21 +475,19 @@ zyre_peer_address (zyre_t *self, const char *peer)
}

// --------------------------------------------------------------------------
// Return the value of a header of a conected peer.
// Returns null if peer or key doesn't exits. Caller
// owns the string
// Return the value of a header of a conected peer. Returns null if peer
// or key doesn't exits. Caller owns the string.

char *
zyre_peer_header_value (zyre_t *self, const char *peer, const char *name)
{
assert (self);
assert (peer);
assert (name);
char *value;
zstr_sendm (self->actor, "PEER HEADER");
zstr_sendm (self->actor, peer);
zstr_send (self->actor, name);
value = zstr_recv (self->actor);
return value;
return zstr_recv (self->actor);
}

// --------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions src/zyre_peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ zyre_peer_connected (zyre_peer_t *self)
// --------------------------------------------------------------------------
// Return peer identity string

char *
const char *
zyre_peer_identity (zyre_peer_t *self)
{
assert (self);
Expand All @@ -237,7 +237,7 @@ zyre_peer_identity (zyre_peer_t *self)
// --------------------------------------------------------------------------
// Return peer connection endpoint

char *
const char *
zyre_peer_endpoint (zyre_peer_t *self)
{
assert (self);
Expand Down Expand Up @@ -285,7 +285,7 @@ zyre_peer_expired_at (zyre_peer_t *self)
// --------------------------------------------------------------------------
// Return peer name

char *
const char *
zyre_peer_name (zyre_peer_t *self)
{
assert (self);
Expand Down Expand Up @@ -366,7 +366,7 @@ zyre_peer_set_ready (zyre_peer_t *self, bool ready)
// --------------------------------------------------------------------------
// Get peer header value

char *
const char *
zyre_peer_header (zyre_peer_t *self, char *key, char *default_value)
{
assert (self);
Expand Down
8 changes: 4 additions & 4 deletions src/zyre_peer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ bool
zyre_peer_connected (zyre_peer_t *self);

// Return peer connection endpoint
char *
const char *
zyre_peer_endpoint (zyre_peer_t *self);

// Send message to peer
int
zyre_peer_send (zyre_peer_t *self, zre_msg_t **msg_p);

// Return peer identity string
char *
const char *
zyre_peer_identity (zyre_peer_t *self);

// Register activity at peer
Expand All @@ -78,7 +78,7 @@ int64_t
zyre_peer_expired_at (zyre_peer_t *self);

// Return peer name
char *
const char *
zyre_peer_name (zyre_peer_t *self);

// Set peer name
Expand Down Expand Up @@ -106,7 +106,7 @@ void
zyre_peer_set_ready (zyre_peer_t *self, bool ready);

// Get peer header value
char *
const char *
zyre_peer_header (zyre_peer_t *self, char *key, char *default_value);

// Get peer headers table
Expand Down

0 comments on commit a351468

Please sign in to comment.