TsgcWebSocketLoadBalancerServer › Events › OnDisconnect
Fires when any WebSocket connection accepted by the load balancer is closed.
property OnDisconnect: TsgcWSDisconnectEvent;
// TsgcWSDisconnectEvent = procedure(Connection: TsgcWSConnection; Code: Integer) of object
—
OnDisconnect is inherited from the underlying server and is raised for every connection (client or backend) when it is closed. Code carries the WebSocket close code (1000 for a normal close, 1006 when the socket is broken). Do not try to send data back on the connection from this handler, the session is already gone. For notifications that distinguish client and backend lifecycle use OnClientDisconnect and OnServerDisconnect, which provide the load-balancer specific context.
procedure OnDisconnect(Connection: TsgcWSConnection; Code: Integer);
begin
Log(Format('Disconnected %s (code=%d)', [Connection.Guid, Code]));
end;