TsgcWebSocketClientEvents › OnConnect

OnConnect Event

Fires when a WebSocket connection to the server has been successfully established.

Syntax

public event TsgcWSConnectEventHandler OnConnect;
// delegate void TsgcWSConnectEventHandler(TsgcWSConnection Connection)

Default Value

Remarks

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...).

Example


void OnConnect(TsgcWSConnection Connection)
{
  Log("Connected to " + Connection.PeerIP);
  Connection.WriteData("Hello from client");
}

Back to Events