TsgcWSPClient_WAMPEvents › OnDisconnect

OnDisconnect Event

Fires when the underlying transport closes, ending the current WAMP session.

Syntax

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

Default Value

Remarks

Code is the WebSocket close code (for example 1000 for a normal shutdown, 1006 for an abnormal close) or the TCP-level reason when the Broker transport is used. All subscriptions, prefixes and pending RPC state are invalidated on disconnect; after reconnect the server issues a fresh WELCOME with a new session id, so re-register prefixes and re-subscribe from OnWelcome. Pending Call promises should be resolved as errors by the application — WAMP v1 does not guarantee a late CALLERROR for calls in flight at disconnect time.

Example


procedure TForm1.WAMPDisconnect(Connection: TsgcWSConnection; Code: Integer);
begin
  Memo1.Lines.Add(Format('disconnected (code %d)', [Code]));
end;

Back to Events