TsgcWebSocketClientEvents › OnHandshake

OnHandshake Event

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

Syntax

public event TsgcWSHandshakeEventHandler OnHandshake;
// delegate void TsgcWSHandshakeEventHandler(TsgcWSConnection Connection, out TStringList Headers)

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


void OnHandshake(TsgcWSConnection Connection, ref string Headers)
{
  Headers = Headers + Environment.NewLine + "Client: sgcWebSockets";
}

Back to Events