TsgcWebSocketLoadBalancerServerEvents › OnClientDisconnect

OnClientDisconnect Event

Fires when a downstream client session is dropped from the load balancer, either because the client left or because the backend terminated.

Syntax

property OnClientDisconnect: TsgcWSLBClientConnectionEvent;
// TsgcWSLBClientConnectionEvent = procedure(ServerConnection: TsgcWSConnection; ClientConnection: TsgcWSLoadBalancerClientConnection) of object

Default Value

Remarks

OnClientDisconnect mirrors OnClientConnect and is raised when a client that had been paired with a backend server is removed from the load balancer internal tables. ServerConnection identifies the backend that was handling the client and ClientConnection exposes the released TsgcWSLoadBalancerClientConnection so the handler can update metrics, close dependent resources, or deregister the session from an external dashboard. After the event returns the connection objects are no longer used to route traffic.

Example


procedure OnClientDisconnect(ServerConnection: TsgcWSConnection;
  ClientConnection: TsgcWSLoadBalancerClientConnection);
begin
  Log('Client disconnected: ' + ClientConnection.Guid);
end;

Back to Events