Using WebSocket Client in .NET

· Componenti

TsgcWebSocketClient è il .NET wrapper around il sgcWebSockets runtime client. It inherits tutti core WebSocket capabilities da TsgcWebSocketClient_base, giving .NET applicazioni a component-style API per connecting, sending, e ricevendo over WebSockets  

Key Properties

Events

Register evento handlers a react a connessione lifecycle e 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 dati once connected
client.WriteData("Hello WebSocket!");

This snippet mirrors la demo usage: eventi sono wired up prima connecting, chiave proprietà sono configured (host, port, TLS, RFC6455, etc.), e impostazione Active a true initiates la connessione.

With il evento handlers defined (as shown above), il client può log connections, ricevere messages, e inviare dati attraverso WriteData