TsgcWebSocketLoadBalancerServerEvents › OnClientConnect

OnClientConnect Event

Fires when a downstream client finishes the WebSocket handshake against the load balancer and is paired with a backend server.

Syntax

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

Default Value

Remarks

OnClientConnect is raised every time a client session is accepted and routed to one of the registered backends. ServerConnection is the backend TsgcWSConnection that will receive the forwarded traffic, while ClientConnection is the TsgcWSLoadBalancerClientConnection that wraps the downstream session and exposes client metadata (Guid, PeerIP, protocol, binding, selected server). Use the event to log client-to-backend assignments, build dashboards, or populate a session map. The event is distinct from OnConnect, which is inherited from the HTTP server and fires for any connection accepted at the socket level.

Example


procedure OnClientConnect(ServerConnection: TsgcWSConnection;
  ClientConnection: TsgcWSLoadBalancerClientConnection);
begin
  Log(Format('Client %s routed to backend %s',
    [ClientConnection.Guid, ServerConnection.Guid]));
end;

Back to Events