TsgcWebSocketClientEvents › OnError

OnError Event

Fires every time a WebSocket protocol error occurs on the connection.

Syntax

public event TsgcWSErrorEventHandler OnError;
// delegate void TsgcWSErrorEventHandler(TsgcWSConnection Connection, string Error)

Default Value

Remarks

OnError reports protocol-level problems detected by the WebSocket layer, such as an invalid message type, a malformed frame, or an invalid UTF-8 payload when Options.ValidateUTF8 is enabled. The Error parameter contains a textual description of the failure; the Connection parameter identifies the affected session. For unhandled exceptions (socket errors, access violations...) use OnException instead. This event does not close the connection by itself.

Example


private void OnError(TsgcWSConnection Connection, string aError)
{
  Console.WriteLine("#error: " + aError);
}

Back to Events