Sometimes there are errors in communications: the server can disconnect a connection because it is not authorized or a message does not have the correct format. There are 2 events where errors are captured.
This event is fired every time there is an error in WebSocket protocol, like invalid message type, invalid utf8 string...
private void OnError(TsgcWSConnection Connection, string aError)
{
Console.WriteLine("#error: " + aError);
}
This event is fired every time there is an exception, such as writing to a socket that is not active or accessing an object that does not exist.
private void OnException(TsgcWSConnection Connection, Exception E)
{
Console.WriteLine("#exception: " + E.Message);
}
By default, when a connection is closed by the server, an exception will be fired. If you do not want these exceptions to be fired, disable Options.RaiseDisconnectExceptions.