TsgcWebSocketClientEvents › OnHandshake

OnHandshake Event

Fires when the client HTTP handshake is being built so custom headers can be added.

Syntax

property OnHandshake: TsgcWSHandshakeEvent;
// TsgcWSHandshakeEvent = procedure(Connection: TsgcWSConnection; var Headers: TStringList) of object

Default Value

Remarks

OnHandshake is raised on the client just before the HTTP Upgrade request is sent to the server. The Headers parameter is a TStringList containing the handshake lines that will be transmitted; add additional lines (for example a custom authorization token or a vendor-specific header) to have them included in the upgrade request. Standard WebSocket headers (Host, Upgrade, Connection, Sec-WebSocket-Key...) are already populated by the component and should not be duplicated.

Example


procedure OnHandshake(Connection: TsgcWSConnection; var Headers: TStringList);
begin
  Headers.Add('Client: sgcWebSockets');
end;

Back to Events