TsgcTCPClient › Events › OnDisconnect
Fires when the TCP connection has been dropped or closed.
property OnDisconnect: TsgcWSDisconnectEvent;
// TsgcWSDisconnectEvent = procedure(Connection: TsgcWSConnection; Code: Integer) of object
—
OnDisconnect is raised whenever the TCP session ends, either because the application set Active to False, the server closed its side of the socket, or the connection was dropped unexpectedly. The Code parameter carries a numeric reason code reported by the transport (0 for a local/clean close); it mirrors the WebSocket disconnect signature for API compatibility, but on a plain TCP connection there is no close frame, so the value simply describes the local shutdown condition. 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.
procedure OnDisconnect(Connection: TsgcWSConnection; Code: Integer);
begin
Log(Format('Disconnected (code %d)', [Code]));
end;