Browse Source

Don't destroy disconnectReason so quickly

tags/docs-0.9
Brandon Smith 9 years ago
parent
commit
8f7492c246
3 changed files with 10 additions and 4 deletions
  1. +4
    -1
      src/Discord.Net/DiscordDataSocket.cs
  2. +4
    -1
      src/Discord.Net/DiscordVoiceSocket.cs
  3. +2
    -2
      src/Discord.Net/DiscordWebSocket.cs

+ 4
- 1
src/Discord.Net/DiscordDataSocket.cs View File

@@ -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; }


+ 4
- 1
src/Discord.Net/DiscordVoiceSocket.cs View File

@@ -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();


+ 2
- 2
src/Discord.Net/DiscordWebSocket.cs View File

@@ -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)
{


Loading…
Cancel
Save