TsgcWebSocketFirewall › Methods › IsSubprotocolAllowed
Checks the requested WebSocket subprotocol name against WebSocketProtection.AllowedSubprotocols and returns whether it is accepted.
function IsSubprotocolAllowed(const aSubprotocol: string): Boolean;
| Name | Type | Description |
|---|---|---|
aSubprotocol | const string | Subprotocol token sent by the client in the Sec-WebSocket-Protocol handshake header (e.g. "mqtt" or "wamp.2.json"). |
True when the subprotocol is whitelisted, WebSocketProtection is disabled, or AllowedSubprotocols is empty; False when the list is populated and no entry matches. (Boolean)
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.
sgcWebSocketFirewall1.WebSocketProtection.AllowedSubprotocols.Add('mqtt');
if not sgcWebSocketFirewall1.IsSubprotocolAllowed('binary') then
Reject := True;