TsgcWebSocketClient › Events › OnHandshake
Fires when the client HTTP handshake is being built so custom headers can be added.
property OnHandshake: TsgcWSHandshakeEvent;
// TsgcWSHandshakeEvent = procedure(Connection: TsgcWSConnection; var Headers: TStringList) of object
—
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.
procedure OnHandshake(Connection: TsgcWSConnection; var Headers: TStringList);
begin
Headers.Add('Client: sgcWebSockets');
end;