Don't destroy disconnectReason so quickly
This commit is contained in:
@@ -42,7 +42,10 @@ namespace Discord
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_disconnectReason.Throw();
|
||||
if (_disconnectReason == null)
|
||||
throw new Exception("An unknown websocket error occurred.");
|
||||
else
|
||||
_disconnectReason.Throw();
|
||||
}
|
||||
try { _connectWaitOnLogin2.Wait(cancelToken); } //Waiting on READY handler
|
||||
catch (OperationCanceledException) { return; }
|
||||
|
||||
@@ -109,7 +109,10 @@ namespace Discord
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_disconnectReason.Throw();
|
||||
if (_disconnectReason == null)
|
||||
throw new Exception("An unknown websocket error occurred.");
|
||||
else
|
||||
_disconnectReason.Throw();
|
||||
}
|
||||
|
||||
SetConnected();
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Discord
|
||||
await DisconnectAsync();
|
||||
|
||||
_disconnectToken = new CancellationTokenSource();
|
||||
_disconnectReason = null;
|
||||
var cancelToken = _disconnectToken.Token;
|
||||
|
||||
_webSocket = new ClientWebSocket();
|
||||
@@ -78,8 +79,7 @@ namespace Discord
|
||||
_webSocket = null;
|
||||
byte[] ignored;
|
||||
while (_sendQueue.TryDequeue(out ignored)) { }
|
||||
|
||||
_disconnectReason = null;
|
||||
|
||||
_task = null;
|
||||
if (_isConnected)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user