new GuardedSocket()
- Description:
A guarded socket with an attached mailbox.
The socket uses the mailbox to store all outgoing messages, and removes them from the mailbox only when the server acknowledges their receipt. The socket resends mailbox upon re-connection. Extends https://socket.io/docs/client-api/#Socket.
- Source:
- See:
-
- socket
Methods
disconnect()
- Description:
Wraps socket.io regular disconnect with a call to a hook before disconnection
- Source:
is_empty()
- Description:
Checks if the socket mailbox is empty (all communication was done and acknowledged), used in safe_disconnect
- Source:
resend_mailbox()
- Description:
Re-sends all pending messages
- Source:
safe_disconnect(freeopt, callbackopt)
- Description:
Safe disconnect: disconnect only after all messages (including free) were acknowledged and all pending opens were resolved
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
free |
boolean |
<optional> |
false
|
if true, a free message will be issued prior to disconnecting |
callback |
function |
<optional> |
given callback will be executed after safe disconnection is complete |
safe_emit(label, msg)
- Description:
Safe emit: stores message in the mailbox until acknowledgment is received, results in socket.emit(label, msg) call(s)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
label |
string | the label given to the message |
msg |
string | the message to send |