Constructor
# new WsClient(option, authenticationTokenopt)
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
option |
Object |
Properties
|
|||||||||||||
authenticationToken |
* |
<optional> |
If you want to authenticate the user set this and validate it on server |
- Source:
Methods
# (async) connect() → {Promise}
Start ws connection, you need to call this method to make a connection
- Source:
Returns:
resolve the promise when the connection is established
- Type
- Promise
# getTotMessages() → {Number}
- Source:
Returns:
Total number of message sent
- Type
- Number
# onConnectionFailure(callback)
Set the callback to call when the connection goes down
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | zero parameter function called when connection is down |
- Source:
# onConnectionReestablished(callback)
Set the callback to call when the connection comes back online
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | zero parameter function called when the connection comes back online |
- Source:
# 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 |
onMessageCallbackClient | Callback where to receive the message |
- Source:
# (async) send(channel, data)
Send message to server
Parameters:
Name | Type | Description |
---|---|---|
channel |
string | Channel name (server need to listen on it with onMessage() ) |
data |
* | Data to be sent |
- Source:
# setAuthenticationToken()
use this to change your authenticationToken
- Source: