TsgcWebSocketServer_HTTPAPI › Events › OnConnect
Fires every time a WebSocket connection is established with a client.
property OnConnect: TsgcWSConnectEvent;
// TsgcWSConnectEvent = procedure(Connection: TsgcWSConnection) of object
—
OnConnect is raised after the WebSocket handshake with a client has completed successfully and the session is ready to exchange frames over the underlying HTTP.SYS request. The Connection parameter identifies the new session and exposes its Guid, PeerIP, protocol, authentication state, and custom tag. Because the HTTP API server routes every request through the kernel first, plain TCP connections are not handled here; use OnTCPConnect when you need to be notified about the initial socket accept or to treat a client as raw TCP.
procedure OnConnect(Connection: TsgcWSConnection);
begin
Log('Client connected: ' + Connection.Guid + ' from ' + Connection.PeerIP);
end;