TsgcWebSocketProxyServer › Events › OnTCPConnect
Fires after a downstream 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 downstream TCP connection is accepted and BEFORE the WebSocket handshake. It is useful when the proxy accepts plain TCP downstream 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 downstream peer as a raw TCP session from the start. Set Accept to False to reject the connection immediately; leave it True (the default) to let the proxy proceed with protocol detection or the WebSocket handshake. The event refers to the downstream socket only; the upstream TCP link is opened later in OnConnect.
procedure OnTCPConnectEvent(aConnection: TsgcWSConnection; var Accept: Boolean);
begin
aConnection.Transport := trpTCP;
Accept := True;
end;