Namespace: connection
Functions
connect
▸ connect<AuthPayload
, ServerMessageTypes
>(payload
, onMessage
): void
Connect to a WebSocket server and send an authentication message once the connection is established. The connection will be reconnected automatically in case of network errors and the authentication message will be re-sent.
The authentication message’s action
property will be set to auth
so that the server can map
the action to the proper authentication handler.
Type parameters
Name |
---|
AuthPayload |
ServerMessageTypes |
Parameters
Name | Type | Description |
---|---|---|
payload |
AuthPayload |
- |
onMessage |
(message : ServerMessageTypes ) => void |
Callback for handling messages from the server |
Returns
void
disconnect
▸ disconnect(): void
Disconnect from the WebSocket server.
Returns
void
send
▸ send<T
>(message
, mode?
): void
Send a message to the WebSocket server with optional automatic retries. If retries are enabled
a unique id will be generated for the message and it will be re-sent until the server responds
with and ack
message for the id.
Type parameters
Name | Type |
---|---|
T |
extends ClientAckMessage |
Parameters
Name | Type | Description |
---|---|---|
message |
T |
Message to send |
mode? |
"required" |
Set to required to enable automatic retries |
Returns
void