Constructor
new ZyrePeer(options)
Parameters:
Name |
Type |
Description |
options |
object
|
Options object
Properties
Name |
Type |
Attributes |
Default |
Description |
identity |
string
|
|
|
Identity of the peer |
originID |
Buffer
|
|
|
16 byte UUID as Buffer |
evasive |
number
|
<optional>
|
5000
|
Evasive timeout in ms |
expired |
number
|
<optional>
|
30000
|
Expired timeout in ms |
|
- Source:
Extends
Methods
(protected) _clearTimeouts()
Clears the evasive and expired timeouts.
- Source:
(protected) _createHandler()
Creates handler as object properties in a separate method to ensure proper scope via arrow
functions.
- Source:
(protected) _evasiveHandler()
Send PING message to evasive peer to check if it is still alive.
- Source:
(protected) _expiredHandler()
Disconnect from the peer when it is expired.
- Source:
Fires:
(protected) _setAddress(address, mailbox) → {boolean}
Sets the endpoint of the peer if it isn't connected yet. Disconnects from the peer and
returns false if the received mailbox port equals 0.
Parameters:
Name |
Type |
Description |
address |
string
|
IP of the peer |
mailbox |
number
|
Network port of the peer |
- Source:
Fires:
Returns:
-
Type
-
boolean
(protected) _setEndpoint(endpoint)
Parameters:
Name |
Type |
Description |
endpoint |
string
|
TCP address of the peer |
- Source:
Parameters:
Name |
Type |
Description |
headers |
object
|
Headers of the peer |
- Source:
(protected) _setName(name)
Parameters:
Name |
Type |
Description |
name |
string
|
Name of the peer |
- Source:
(protected) _setSequence(sequence) → {boolean}
Sets the sequence number of the last received message. Disconnects from the peer and returns
false if the sequence number does not equal the expected one.
Parameters:
Name |
Type |
Description |
sequence |
number
|
Sequence of the last received message |
- Source:
Fires:
Returns:
-
Type
-
boolean
(protected) _setStatus(status)
Parameters:
Name |
Type |
Description |
status |
number
|
Group status of the peer |
- Source:
(protected) _setTimeouts()
Sets timeouts for evasive and expired.
- Source:
Fires:
addToGroup(group)
Adds this ZyrePeer to a given ZyreGroup.
Parameters:
Name |
Type |
Description |
group |
ZyreGroup
|
ZyreGroup |
- Source:
connect()
Connects to this ZyrePeer.
- Source:
disconnect()
Disconnects from this ZyrePeer and stops every activity. Closes the zeromq dealer socket. Loses
all pending messages, so only use when the peer should be permanently removed.
- Source:
Fires:
removeFromGroup(group)
Removes this ZyrePeer from a given ZyreGroup.
Parameters:
Name |
Type |
Description |
group |
ZyreGroup
|
ZyreGroup |
- Source:
send(msg)
Sends a ZreMsg to this ZyrePeer.
Parameters:
Name |
Type |
Description |
msg |
ZreMsg
|
ZreMsg |
- Source:
Creates an object with public data of this peer.
- Source:
Returns:
-
Type
-
PeerObject
update(options) → {ZyrePeer}
Updates the data of this ZyrePeer, manages timeouts for evasive and expired.
Parameters:
Name |
Type |
Description |
options |
object
|
Options object
Properties
Name |
Type |
Attributes |
Description |
sequence |
number
|
<optional>
|
Sequence of the last received message |
address |
string
|
<optional>
|
IP of the peer |
mailbox |
number
|
<optional>
|
Network port of the peer |
endpoint |
string
|
<optional>
|
TCP address of the peer |
status |
number
|
<optional>
|
Group status of the peer |
name |
string
|
<optional>
|
Name of the peer |
headers |
object
|
<optional>
|
Headers of the peer |
|
- Source:
Fires:
Returns:
-
Type
-
ZyrePeer
Events
disconnect
Properties:
Name |
Type |
Description |
zyrePeer |
ZyrePeer
|
ZyrePeer |
- Source:
expired
Properties:
Name |
Type |
Description |
zyrePeer |
ZyrePeer
|
ZyrePeer |
- Source: