Supported by
By default, sgcWebSocket uses WebSocket as the protocol, but you can use plain TCP protocol in client and server components.
Client Component
Disable WebSocket protocol.
Client.Specifications.RFC6455 = false;
Server Component
Handle event OnUnknownProtocol and set Transport as trpTCP and Accept the connection.
void OnUnknownProtocol(TsgcWSConnection Connection, ref bool Accept)
{
Accept = true;
}
Then when a client connects to the server, this connection will be defined as TCP and will use plain TCP protocol instead of WebSockets. Plain TCP connections do not distinguish between text and binary messages, so all messages received are handled by the OnBinary event.
End of Message
If messages are large, they can sometimes be received fragmented. There is a method to detect the end of a message by specifying which bytes to look for. Example: in the STOMP protocol, all messages end with bytes 0 and 10.
void OnWSClientConnect(TsgcWSConnection Connection)
{
Connection.SetTCPEndOfFrameScanBuffer(TtcpEOFScanBuffer.eofScanAllBytes);
Connection.AddTCPEndOfFrame(0);
Connection.AddTCPEndOfFrame(10);
}