Members
readyState :number
- Description:
Reay state of the underlying socket instance.
- Source:
- See:
Reay state of the underlying socket instance.
Type:
- number
sockets :ServerSockets
- Description:
Reference to the @link{ServerSockets} instance.
Allows for broadcasting from a given socket instance.
- Source:
Reference to the @link{ServerSockets} instance.
Allows for broadcasting from a given socket instance.
Type:
Example
socket.sockets.broadcast('my-room', this, 'update-value', 1);
(static) ServerSocket :object
- Description:
ws
socket instance configured withbinaryType=blob
(string)
- Source:
ws
socket instance configured with binaryType=blob
(string)
Type:
- object
(static) ServerSocket :ServerSockets
- 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
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 ServerSocket#send method. |
addToRoom(roomId)
- Description:
Add the socket to a room
- Source:
Parameters:
Name | Type | Description |
---|---|---|
roomId |
string | Id of the room. |
removeAllListeners(channel)
- Description:
Remove all listeners of messages with JSON compatible data types.
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
channel |
string |
null
|
Channel name. |
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). |