TsgcWebSocketClient | Client Register Protocol

By default, TsgcWebSocketClient doesn't make use of any SubProtocol, basically websocket sub-protocol are built on top of websocket protocol and defines a custom message protocol, example of websocket sub-protocols can be MQTT, STOMP...

 

WebSocket SubProtocol name is sent as an HTTP Header in WebSocket HandShake, this header is processed by server and if server supports this subprotocol will accept connection, if is not supported, connection will be closed automatically

 

Example: connect to a websocket server with SubProtocol name 'myprotocol'

 


Client := TsgcWebSocketClient.Create(nil);
Client.Host := 'server host';
Client.Port := server.port;
Client.RegisterProtocol('myprotocol');
Client.Active := True;