TsgcWebSocketClientEvents › OnException

OnException Event

Fires whenever an unhandled exception is raised while processing the connection.

Syntax

public event TsgcExceptionEventHandler OnException;
// delegate void TsgcExceptionEventHandler(TsgcWSConnection Connection, Exception E)

Default Value

Remarks

OnException is fired whenever an exception escapes internal processing, for example when writing to a socket that is no longer active, accessing a released object, or when the server closes the connection while a read is in progress. The E parameter exposes the exception instance so the application can log the message or react to specific classes. By default a disconnection from the server raises an exception here; set Options.RaiseDisconnectExceptions to False to suppress those disconnect-related exceptions.

Example


private void OnException(TsgcWSConnection Connection, Exception E)
{
  Console.WriteLine("#exception: " + E.Message);
}

Back to Events