TsgcWebSocketProxyServer › Events › OnDisconnect
Fires every time a WebSocket connection with a downstream client is dropped and the upstream TCP session is closed.
property OnDisconnect: TsgcWSDisconnectEvent;
// TsgcWSDisconnectEvent = procedure(Connection: TsgcWSConnection; Code: Integer) of object
—
OnDisconnect is raised whenever an active downstream client session ends, either because the application called Disconnect or DisconnectAll, the client closed the connection, or the TCP socket was dropped unexpectedly. The upstream TCP connection that the proxy had paired with this session is closed at the same time, so no more data will be forwarded in either direction. 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.
procedure OnDisconnect(Connection: TsgcWSConnection; Code: Integer);
begin
Log(Format('Client %s disconnected (code %d)', [Connection.Guid, Code]));
end;