TsgcWSPServer_sgcEvents › OnDisconnect

OnDisconnect Event

Fires when a client disconnects from the server.

Syntax

property OnDisconnect: TsgcWSDisconnectEvent;
// TsgcWSDisconnectEvent = procedure(Connection: TsgcWSConnection; Code: Integer) of object

Default Value

Remarks

Raised after the connection is closed, for any reason (client-initiated, server-initiated, or socket error). Before the event fires the subprotocol cleans up the connection's QoS entries and releases every subscription, so subscriber lists observed in other handlers no longer include this client. Code carries the WebSocket close code (1000 for a clean shutdown).

Example

procedure TForm1.oProtocolDisconnect(Connection: TsgcWSConnection; Code: Integer);
begin
  Memo1.Lines.Add(Format('%s left with code %d', [Connection.Guid, Code]));
end;

Back to Events