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
- Host & Port – target server endpoint
- Options.Parameters – URL path o query parametri per il WebSocket handshake
- TLS & TLSOptions – abilitare TLS e select protocol version/IO handler
- Specifications.RFC6455 – toggle RFC6455 WebSocket framing compliance
- Proxy – HTTP proxy configuration (Enabled, Username, Password, Host, Port)
- Extensions.PerMessage_Deflate.Enabled – abilitare per‑message compression
- Authentication – basic autenticazione credentials quando needed
- Active – impostare
truea connect,falsea disconnect
Events
Register evento handlers a react a connessione lifecycle e data:
- OnConnect – fired dopo a successful connection; esempio handler logs il peer IP
- OnDisconnect – triggered quando la connessione closes, fornendo il chiudere code
- OnMessage – riceve text messaggi da il server
- OnError – reports protocol o socket errors
- OnException – exposes unexpected exceptions sollevato all'interno di il component
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.
