TsgcHTTPServer › 事件 › OnConnect
每次与客户端建立连接时触发。
property OnConnect: TsgcWSConnectEvent;
// TsgcWSConnectEvent = procedure(Connection: TsgcWSConnection) of object
—
OnConnect 在客户端连接被接受并准备好交换 HTTP 请求后触发。Connection 参数标识新会话,并公开其 Guid、PeerIP、身份验证状态和自定义标签。使用 OnTCPConnect 可在 TCP 套接字被接受的那一刻收到通知,即在 HTTP 层接管之前。
procedure OnConnect(Connection: TsgcWSConnection);
begin
Log('Client connected: ' + Connection.Guid + ' from ' + Connection.PeerIP);
end;