This demo shows how connect to a Socket.IO Server. Requires a TsgcWebSocketClient to handle WebSocket / TCP protocols.
SOCKETIO.Client := WSClient;
WSClient.Host := 'socketio-chat-h9jt.herokuapp.com';
WSClient.Port := 443;
WSClient.Options.Parameters := '/';
WSClient.Specifications.RFC6455 := True;
WSClient.TLS := True;
Socket.IO uses TsgcWebSocketClient to send messages to server, so just call WriteData and pass as a parameter the JSON message to socket.io server
WSClient.WriteData('42["new message", "' + txtSocketIOMessage.Text + '"]');
The messages received as the flow of connection is handled by TsgcWebSocketClient, so use this component to read the messages sent from server and to know if connection is active or not.
procedure TfrmWebSocketClient.WSClientMessage(Connection: TsgcWSConnection;
const Text: string);
begin
DoLog(Text);
end;