Methods
# (inner) addToGroup(identifier, ws)
Add a user to a group
Parameters:
Name | Type | Description |
---|---|---|
identifier |
string | group identifier |
ws |
WebSocket | Websocket client instance |
- Source:
# (inner) addUser(identifier, ws)
Remember a user identified by an identifier
Parameters:
Name | Type | Description |
---|---|---|
identifier |
string | User identifier |
ws |
WebSocket | Websocket client instance |
- Source:
# (inner) checkAuthentication(callback)
Set the callback to validate authenticationToken
Parameters:
Name | Type | Description |
---|---|---|
callback |
checkAuthenticationCallback | Function where you can validate the authenticationToken |
- Source:
# (inner) deleteGroup(identifier)
Delete a group by identifier
Parameters:
Name | Type | Description |
---|---|---|
identifier |
string | Group identifier |
- Source:
# (inner) deleteUser(identifier)
Delete a user by identifier
Parameters:
Name | Type | Description |
---|---|---|
identifier |
string | User identifier |
- Source:
# (async, inner) init(wsInstance) → {Promise}
Initiate ws-redis
Parameters:
Name | Type | Description |
---|---|---|
wsInstance |
WebSocket | WebSocket server instance |
Returns:
Promise object rapresents the redis status
- Type
- Promise
# (inner) onClientClosed(callback)
Set the callback where to be notified when user close the connection
Parameters:
Name | Type | Description |
---|---|---|
callback |
onClientClosedCallback | Callback where to be notified when user close the connection |
- Source:
# (inner) onConnection(callback)
Set the callback to call when a new user is connected
Parameters:
Name | Type | Description |
---|---|---|
callback |
onConnectionCallback | Callback where to receive new user connection |
- Source:
# (inner) onMessage(channel, callback)
Set the callback to call when the user receive a message
Parameters:
Name | Type | Description |
---|---|---|
channel |
string | Channel name to listen to |
callback |
onMessageCallbackServer | Callback where to receive the message |
- Source:
# (inner) sendMessageToGroup(identifier, channel, data, pubOnRedisopt)
Send message to all users in the given group
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
identifier |
string | Group name | ||
channel |
string | Channel name (clients will receive a message on this channel) | ||
data |
* | Data to send | ||
pubOnRedis |
boolean | <optional> |
true | Whether to publish on redis to ensure delivery to all clients |
# (inner) sendMessageToUser(identifier, channel, data)
Send message to a specific user
Parameters:
Name | Type | Description |
---|---|---|
identifier |
string | Username / user identifier |
channel |
string | Channel name (client will receive a message on this channel) |
data |
* | Data to send |