Members
config :object
- Description:
Configuration object
- Source:
Configuration object
Type:
- object
sockets :server.Sockets
- Description:
Reference to the sockets object, is mainly dedicated to allow broadcasting from a given socket instance.
- Source:
Reference to the sockets object, is mainly dedicated to allow broadcasting from a given socket instance.
Type:
Example
socket.sockets.broadcast('my-room', this, 'update-value', 1);
Methods
addBinaryListener(channel, callback)
- Description:
Listen binary messages on a given channel
- Source:
Parameters:
Name | Type | Description |
---|---|---|
channel |
string | Channel name. |
callback |
function | Callback to execute when a message is received. |
addListener(channel, callback)
- Description:
Listen messages with JSON compatible data types on a given channel.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
channel |
string | Channel name. |
callback |
function | Callback to execute when a message is received, arguments of the callback function will match the arguments sent using the server.Socket#send method. |
addToRoom(roomId)
- Description:
Add the socket to a room
- Source:
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Id of the room. |
removeAllBinaryListeners(channel)
- Description:
Remove all listeners of binary compatible messages on a given channel
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
channel |
string |
null
|
Channel of the message. |
removeAllListeners(channel)
- Description:
Remove all listeners of messages with JSON compatible data types.
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
channel |
string |
null
|
Channel name. |
removeBinaryListener(channel, callback)
- Description:
Remove a listener of binary compatible messages from a given channel
- Source:
Parameters:
Name | Type | Description |
---|---|---|
channel |
string | Channel name. |
callback |
function | Callback to remove. |
removeFromRoom(roomId)
- Description:
Remove the socket from a room
- Source:
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Id of the room. |
removeListener(channel, callback)
- Description:
Remove a listener of messages with JSON compatible data types from a given channel.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
channel |
string | Channel name. |
callback |
function | Callback to remove. |
send(channel, …args)
- Description:
Send messages with JSON compatible data types on a given channel.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
channel |
string | Channel name. |
|
args |
* |
<repeatable> |
Payload of the message. As many arguments as needed, of JSON compatible data types (i.e. string, number, boolean, object, array and null). |
sendBinary(channel, typedArray)
- Description:
Send binary messages on a given channel.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
channel |
string | Channel name. |
typedArray |
TypedArray | Binary data to be sent. |