TsgcWebSocketFirewallMethods › IsSubprotocolAllowed

IsSubprotocolAllowed Method

Checks the requested WebSocket subprotocol name against WebSocketProtection.AllowedSubprotocols and returns whether it is accepted.

Syntax

function IsSubprotocolAllowed(const aSubprotocol: string): Boolean;

Parameters

NameTypeDescription
aSubprotocolconst stringSubprotocol token sent by the client in the Sec-WebSocket-Protocol handshake header (e.g. "mqtt" or "wamp.2.json").

Return Value

True when the subprotocol is whitelisted, WebSocketProtection is disabled, or AllowedSubprotocols is empty; False when the list is populated and no entry matches. (Boolean)

Remarks

Matching is case-insensitive. The helper is normally invoked by the server integration during the handshake; call it directly when implementing custom handshake logic that needs to restrict subprotocol negotiation.

Example

sgcWebSocketFirewall1.WebSocketProtection.AllowedSubprotocols.Add('mqtt');
if not sgcWebSocketFirewall1.IsSubprotocolAllowed('binary') then
  Reject := True;

Back to Methods