TsgcWebSocketServer  | Server Plain TCP

The WebSocket server accepts WebSocket, HTTP, SSE, and other protocols, but can also work with plain TCP connections. Read more about TCP Connections.

 

There are 2 events that can be used to handle TCP connections.

 

OnTCPConnect

 

This event is called after a client connects to the server and before any handshake between client and server. The OnConnect event is only fired after the client sends a message (to allow the server to detect which protocol is being used).

 

This event allows you to know that a new client is trying to connect to the server, and the server can accept or reject the connection. By default, the server always accepts the connection.

 

 

OnUnknownProtocol

 

This event is called when the server receives the first message from a client but cannot detect whether it is any of the known protocols. In this event, the server can accept or reject the protocol.

 

 

OnConnect

 

This event is fired after a successful and complete connection. If the connection is plain TCP, it is fired after the protocol is accepted in the OnUnknownProtocol event.