Constructor
new Zyre(options)
Parameters:
Name |
Type |
Description |
options |
object
|
Options object
Properties
Name |
Type |
Attributes |
Default |
Description |
name |
string
|
<optional>
|
|
Name of the zyre node |
iface |
string
|
<optional>
|
|
Network interface or IPv4 address |
headers |
object
|
<optional>
|
|
Optional headers, sent to every peer on discovery |
evasive |
number
|
<optional>
|
5000
|
Evasive timeout in ms |
expired |
number
|
<optional>
|
30000
|
Expired timeout in ms |
port |
number
|
<optional>
|
49152
|
Port for incoming messages, will be incremented if used |
bport |
number
|
<optional>
|
5670
|
Broadcast beacon port |
binterval |
number
|
<optional>
|
1000
|
Broadcast beacon interval in ms |
|
- Source:
Extends
Methods
(static) new(options) → {Zyre}
Returns a new Zyre instance.
Parameters:
Name |
Type |
Description |
options |
object
|
Options object
Properties
Name |
Type |
Attributes |
Default |
Description |
name |
string
|
<optional>
|
|
Name of the zyre node |
iface |
string
|
<optional>
|
|
Network interface to use |
headers |
object
|
<optional>
|
|
Optional headers, sent to every peer on discovery |
evasive |
number
|
<optional>
|
5000
|
Evasive timeout in ms |
expired |
number
|
<optional>
|
30000
|
Expired timeout in ms |
port |
number
|
<optional>
|
49152
|
Port for incoming messages, will be incremented if used |
bport |
number
|
<optional>
|
5670
|
Broadcast beacon port |
binterval |
number
|
<optional>
|
1000
|
Broadcast beacon interval in ms |
|
- Source:
Returns:
-
Type
-
Zyre
(protected) _createHandler()
Creates handler as object properties in a separate method to ensure proper scope via arrow
functions.
- Source:
(protected) _getEncodedContent(content) → {string|Buffer}
Returns the encoded content of the ZreMsg. Encoding is set by setEncoding(encoding).
Parameters:
Name |
Type |
Description |
content |
Buffer
|
Content of a ZreMsg |
- Source:
Returns:
-
Type
-
string
|
Buffer
Returns an object with information of the ZyreGroup with the given name.
Parameters:
Name |
Type |
Description |
name |
string
|
Name of the group |
- Source:
Returns:
-
Type
-
PeersObject
Returns an object with information of all ZyreGroups.
- Source:
Returns:
-
Type
-
GroupsObject
getIdentity() → {string}
- Source:
Returns:
Identity
-
Type
-
string
getPeer(identity) → {PeerObject}
Returns an object with information of the ZyrePeer with the given identity.
Parameters:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
- Source:
Returns:
-
Type
-
PeerObject
Returns an object with information of all ZyrePeers.
- Source:
Returns:
-
Type
-
PeersObject
join(group)
Joins a group.
Parameters:
Name |
Type |
Description |
group |
string
|
Name of the group |
- Source:
leave(group)
Leaves a group.
Parameters:
Name |
Type |
Description |
group |
string
|
Name of the group |
- Source:
setEncoding(encodingnullable)
Sets the encoding of received messages. Defaults to utf8.
Parameters:
Name |
Type |
Attributes |
Description |
encoding |
string
|
<nullable>
|
Encoding of messages |
- Source:
shout(group, message)
Sends a message to a ZyreGroup.
Parameters:
Name |
Type |
Description |
group |
string
|
Name of the group |
message |
string
|
Buffer
|
Message to send |
- Source:
start(callback) → {Promise}
Finds a free TCP port on the host, starts the ZyreNode and the ZBeacon, adds listeners.
Executes the callback or returns a Promise on success.
Parameters:
Name |
Type |
Description |
callback |
function
|
Executed on success |
- Source:
Fires:
Returns:
-
Type
-
Promise
stop(callback) → {Promise}
Stops listening, closes all sockets, removes all event listeners and disconnects from all
peers. Executes the callback or returns a Promise on success.
Parameters:
Name |
Type |
Description |
callback |
function
|
Executed on success |
- Source:
Returns:
-
Type
-
Promise
whisper(identity, message)
Sends a message to a ZyrePeer.
Parameters:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
message |
string
|
Buffer
|
Message to send |
- Source:
Events
connect
Properties:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
name |
string
|
Name of the peer |
headers |
object
|
Headers of the peer |
- Source:
disconnect
Properties:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
name |
string
|
Name of the peer |
- Source:
expired
Properties:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
name |
string
|
Name of the peer |
- Source:
join
Properties:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
name |
string
|
Name of the peer |
group |
string
|
Group which the peer joins |
- Source:
leave
Properties:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
name |
string
|
Name of the peer |
group |
string
|
Group which the peer leaves |
- Source:
shout
Properties:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
name |
string
|
Name of the peer |
message |
string
|
Buffer
|
Message |
group |
string
|
Group where the message came from |
- Source:
whisper
Properties:
Name |
Type |
Description |
identity |
string
|
Identity of the peer |
name |
string
|
Name of the peer |
message |
string
|
Buffer
|
Message |
- Source: