Supported by
By default, sgcWebSocket use WebSocket as 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.
procedure OnUnknownProtocol(Connection: TsgcWSConnection; var Accept: Boolean);
begin
Connection.Transport := trpTCP;
Accept := True;
end;
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 don't know if the message is text or binary, so all messages received are handle OnBinary event.
End of Message
If messages are big, sometimes can be received fragmented. There is a method to try to find end of message setting which bytes find. Example: STOMP protocol, all messages ends with byte 0 and 10
procedure OnWSClientConnect(Connection: TsgcWSConnection);
begin
Connection.TCPEndOfFrameScanBuffer := eofScanAllBytes;
Connection.AddTCPEndOfFrame(0);
Connection.AddTCPEndOfFrame(10);
end;