TsgcWebSocketHTTPServer › Events › OnConnect
Fires every time a WebSocket connection is established with a client.
public event TsgcWSConnectEventHandler OnConnect;
// delegate void TsgcWSConnectEventHandler(TsgcWSConnection Connection)
—
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. Plain HTTP requests are delivered through OnCommandGet/OnCommandOther, so this event is only fired for WebSocket-upgraded clients; plain TCP peers raise it after the first message is received or after OnUnknownProtocol accepts the session. Use OnTCPConnect to be notified the moment the TCP socket is accepted.
void OnConnect(TsgcWSConnection Connection)
{
Console.WriteLine("Client connected: " + Connection.Guid + " from " + Connection.PeerIP);
}