TsgcWebSocketServer › Events › OnDisconnect
Fires every time a WebSocket connection with a client is dropped.
public event TsgcWSDisconnectEventHandler OnDisconnect;
// delegate void TsgcWSDisconnectEventHandler(TsgcWSConnection Connection, int Code)
—
OnDisconnect is raised whenever an active client session ends, either because the application called Disconnect or DisconnectAll, the client closed the connection, or the TCP socket 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...). After this event returns the Connection object is no longer valid for sending data, so release any per-session resources you had associated with its Guid.
void OnDisconnect(TsgcWSConnection Connection, int Code)
{
Console.WriteLine("Client " + Connection.Guid + " disconnected (code " + Code + ")");
}