TsgcWebSocketClient › Events › OnConnect
Fires when a WebSocket connection to the server has been successfully established.
public event TsgcWSConnectEventHandler OnConnect;
// delegate void TsgcWSConnectEventHandler(TsgcWSConnection Connection)
—
OnConnect is raised after the TCP socket is open and the WebSocket handshake has completed successfully, meaning the client can start sending messages. Wait for this event before calling WriteData when opening the connection through the Active property or Start; the synchronous Connect method returns only after OnConnect has already been dispatched. The Connection parameter exposes the active session (remote address, protocol, authentication state...).
void OnConnect(TsgcWSConnection Connection)
{
Log("Connected to " + Connection.PeerIP);
Connection.WriteData("Hello from client");
}