TsgcWebSocketClientEvents › OnDisconnect

OnDisconnect Event

Fires when the WebSocket connection has been dropped or closed.

Syntax

public event TsgcWSDisconnectEventHandler OnDisconnect;
// delegate void TsgcWSDisconnectEventHandler(TsgcWSConnection Connection, int Code)

Default Value

Remarks

OnDisconnect is raised whenever the WebSocket session ends, either because the application set Active to False, the server sent a close frame, or the TCP connection was dropped unexpectedly. The Code parameter carries the WebSocket close code reported by the peer (1000 for a normal closure, 1006 for an abnormal drop, etc.). After this event fires the Connection object is no longer valid for sending data; if WatchDog is enabled the client will schedule a reconnection attempt and raise OnBeforeWatchDog before retrying.

Example


void OnDisconnect(TsgcWSConnection Connection, int Code)
{
  Log("Disconnected (code " + Code + ")");
}

Back to Events