TsgcWebSocketServerEvents › OnConnect

OnConnect Event

Fires every time a WebSocket connection is established with a client.

Syntax

property OnConnect: TsgcWSConnectEvent;
// TsgcWSConnectEvent = procedure(Connection: TsgcWSConnection) of object

Default Value

Remarks

OnConnect is raised after the WebSocket handshake with a client has completed successfully and the session is ready to exchange frames. The Connection parameter identifies the new session and exposes its Guid, PeerIP, protocol, authentication state, and custom tag. For plain TCP connections the event is only fired after the first message is received (or after OnUnknownProtocol accepts the protocol); use OnTCPConnect instead if you need to be notified the moment the TCP socket is accepted.

Example


procedure OnConnect(Connection: TsgcWSConnection);
begin
  Log('Client connected: ' + Connection.Guid + ' from ' + Connection.PeerIP);
end;

Back to Events