Using WebSocket Client in .NET

· Components

TsgcWebSocketClient is the .NET wrapper around the sgcWebSockets runtime client. It inherits all core WebSocket capabilities from TsgcWebSocketClient_base, giving .NET applications a component-style API for connecting, sending, and receiving over WebSockets  

Key Properties

Events

Register event handlers to react to connection lifecycle and data:

Example

using esegece.sgcWebSockets;
var client = new TsgcWebSocketClient();
client.OnConnect    += OnConnectEvent;
client.OnDisconnect += OnDisconnectEvent;
client.OnException  += OnExceptionEvent;
client.OnError      += OnErrorEvent;
client.OnMessage    += OnMessageEvent;
client.Host = "www.esegece.com";
client.Port = 2052;
client.Options.Parameters = "/";
client.TLS = false;
client.Specifications.RFC6455 = true;
client.Active = true;
// Sending data once connected
client.WriteData("Hello WebSocket!");

This snippet mirrors the demo usage: events are wired up before connecting, key properties are configured (host, port, TLS, RFC6455, etc.), and setting Active to true initiates the connection.

With the event handlers defined (as shown above), the client can log connections, receive messages, and send data through WriteData