TsgcWebSocketServerGebeurtenissen › OnTCPConnect

OnTCPConnect Gebeurtenis

Wordt geactiveerd nadat een client verbinding maakt op TCP-niveau en vóór de WebSocket-handshake, zodat de verbinding kan worden geaccepteerd of geweigerd.

Syntaxis

property OnTCPConnect: TsgcWSOnTCPConnect;
// TsgcWSOnTCPConnect = procedure(Connection: TsgcWSConnection; var Accept: Boolean) of object

Standaardwaarde

Opmerkingen

OnTCPConnect is called AFTER the TCP verbinding is geaccepteerd and BEFORE the WebSocket handshake. It is nuttig when de server accepts plain TCP connections: standaard OnConnect is only fired after the eerste message is received from de client, so handle deze gebeurtenis and set Verbinding.Transport to trpTCP to treat de client as a raw TCP peer from the start. Set Accept to False to reject the verbinding onmiddellijk; leave it True (de standaardwaarde) to let de server proceed with protocol detection or the WebSocket handshake.

Voorbeeld


procedure OnTCPConnectEvent(aConnection: TsgcWSConnection; var Accept: Boolean);
begin
  aConnection.Transport := trpTCP;
  Accept := True;
end;

Terug naar gebeurtenissen