TsgcWebSocketHTTPServer › Events › OnUnknownProtocol
Fires when the first message does not match a known protocol so the connection can be accepted or rejected.
public event TsgcWSUnknownProtocolEventHandler OnUnknownProtocol;
// delegate void TsgcWSUnknownProtocolEventHandler(TsgcWSConnection Connection, out bool Accept)
—
OnUnknownProtocol is raised when the server receives the first bytes from a connecting client and cannot recognize any of the built-in protocols (WebSocket, HTTP, SSE...). It is typically used to accept plain TCP clients on the same listener that serves HTTP. Set Accept to True to keep the session open (OnConnect will then be fired as a plain TCP connection) or to False to close it. The Connection parameter identifies the session; inspect TsgcWSConnection.Transport or the raw bytes already buffered to decide whether to allow the connection. Unsolicited connections can be rejected here to reduce CPU usage.
void OnUnknownProtocol(TsgcWSConnection Connection, ref bool Accept)
{
Accept = true;
}