SetOnConnectionChanged
You can subscribe to this event and being notified when the connection with the server has been lost or connected successfully.
The rejected state doesn’t give a reason for the rejection. The engine state may give more details. At present, the only reason for rejection is Sym3EngineState.MaxConnectionsExceeded.
Event callback
OnConnectionChanged(state: string)
Parameters
- state (string): can be “open”, “closed”, or “rejected”
Examples
Subscribe to the callback and log the status:
SYM3.SetOnConnectionChanged(onConnectionChanged);
function onConnectionChanged(state)
{
if (state === "open")
console.log("Connection successful");
else if (state === "closed")
console.log("Connection with server has been lost, trying to reconnect...");
else if (state === "rejected")
console.log("Connection was rejected by the server, trying again...");
}