TsgcWebSocketServer › Events › OnTCPConnect
Fires after a client connects at TCP level and before the WebSocket handshake, so the connection can be accepted or rejected.
property OnTCPConnect: TsgcWSOnTCPConnect;
// TsgcWSOnTCPConnect = procedure(Connection: TsgcWSConnection; var Accept: Boolean) of object
—
OnTCPConnect is called AFTER the TCP connection is accepted and BEFORE the WebSocket handshake. It is useful when the server accepts plain TCP connections: by default OnConnect is only fired after the first message is received from the client, so handle this event and set Connection.Transport to trpTCP to treat the client as a raw TCP peer from the start. Set Accept to False to reject the connection immediately; leave it True (the default) to let the server proceed with protocol detection or the WebSocket handshake.
procedure OnTCPConnectEvent(aConnection: TsgcWSConnection; var Accept: Boolean);
begin
aConnection.Transport := trpTCP;
Accept := True;
end;