Methods
broadcastMessage(message)
Send broadcasting messages to all peers excluding previous sender
Parameters:
Name | Type | Description |
---|---|---|
message |
object |
- Source:
createMessage(data, reciver, sender, id, timestamp, TTL, relevancyTime, route, type, timestampOfStart) → {Object}
Create message of starwave type
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Message Data |
reciver |
string | Receiver address |
sender |
string | Sender address |
id |
string | Message id |
timestamp |
number | Message timestamp |
TTL |
number | Message TTL |
relevancyTime |
number | Message lifetime |
route |
object | Routes object |
type |
number | Messages type |
timestampOfStart |
number | Initial message timestamp |
- Source:
Returns:
- Type
- Object
getAddress() → {string}
Returns address
- Source:
Returns:
- Type
- string
getCurrentPeers() → {Array}
Get the list of connected peers(sockets)
- Source:
Returns:
- Type
- Array
getSocketByBusAddress(address) → {*}
find socket using bus address
Parameters:
Name | Type | Description |
---|---|---|
address |
- Source:
Returns:
- Type
- *
manageIncomingMessage(message) → {Boolean}
Disassemble incoming message and decide what we should do with it
Parameters:
Name | Type | Description |
---|---|---|
message |
object |
- Source:
Returns:
- Type
- Boolean
registerMessageHandler(message, handler) → {boolean}
Register message handler
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Message ID |
handler |
function | Handler function |
- Source:
Returns:
- Type
- boolean
sendMessage(message)
Send message using StarWave protocol
Parameters:
Name | Type | Description |
---|---|---|
message |
object | Message object |
- Source:
sendMessageToPeer(messageBusAddress, message)
Send message to peer directly(using busAddress)
Parameters:
Name | Type | Description |
---|---|---|
messageBusAddress |
string | Receiver address |
message |
object | Message object |
- Source:
write(ws, message)
Write to socket
Parameters:
Name | Type | Description |
---|---|---|
ws |
||
message |
- Source: