TsgcWebSocketServer_HTTPAPI › Events › OnTCPConnect
Fires after a client connects at TCP level and before the WebSocket handshake, so the connection can be accepted or rejected.
public event TsgcWSHTTPAPITCPConnectHandler OnTCPConnect;
// delegate void TsgcWSHTTPAPITCPConnectHandler(TsgcWSConnection Connection, out bool Accept)
—
OnTCPConnect is called AFTER the TCP connection is accepted by HTTP.SYS and BEFORE the WebSocket handshake is processed. Use it to inspect Connection.PeerIP or other socket properties and decide whether to proceed. Set Accept to False to reject the connection immediately; leave it True (the default) to let the server proceed with the WebSocket handshake or the normal HTTP request pipeline.
void OnTCPConnectEvent(TsgcWSConnection Connection, ref bool Accept)
{
Accept = Connection.PeerIP != "10.0.0.1";
}