From sgcWebSockets 4.1.6 default SGC Protocol supports wildcards in Subscribe, UnSubscribe and Publish methods, websocket protocol.

Channel is a string used by server to filter messages for each connected client. A channel can consists of one or more levels, usually each topic is separated by a forward slash. Example

  weather/usa/california/San Francisco/Silicon Valley


When a client subscribe to a channel it can use exact channel name or can subscribe to more channels at once by using wildcards. Example:





Wildcards only works for active channels, so you can create some persistent channels before server is started:


  WSPPROTOCOL.Subscriptions.Add(NewGuid + '_' + 'weather/usa/california';

  WSPPROTOCOL.Subscriptions.Add(NewGuid + '_' + 'weather/usa';


Implemented from sgcWebSockets 4.1.4

Supported by:





WebSocket provides a simple subprotocol negotiation, basically adds a header with protocols name supported by request, this protocols are received and if receiver supports one of them, sends a response with subprotocol supported.

sgcWebSockets supports several SubProtocols: MQTT, WAMP... and more. You can implement your own subprotocols using a very easy method, just call RegisterProtocol and send SubProtocol Name as argument.

Example: you need to connect to a server which implements subprotocol "Test 1.0"

Client.Host := server host;

Client.Port := server.port;

Client.RegisterProtocol('Test 1.0');

Client.Active := True;



When a client sends a binary message to server, sometimes is useful set an ID to identify binary message when is received. There are 2 functions in sgcWebSocket_Helpers which can be used to set a short description of binary packet, basically adds a header to stream which is used to identify binary packet.


Before send a binary message, call sgcWSStreamWrite method to encode stream.

   vID := '00001';

   sgcWSStreamWrite(vID, oStream);



When binary message is received, call sgcWSStreamRead method to decode stream.

   sgcWSStreamRead(oStream, vID);


The only limitation is that text used to identify binary message, has a maximum length of 10 characters (this can be modified if you have access to source code).