Browse Source

Don't activate the canceltoken in websockets before the disconnectreason has been set.

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

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

@@ -42,7 +42,7 @@ namespace Discord
}
catch (OperationCanceledException)
{
throw _disconnectReason;
throw _disconnectReason;// ?? new Exception("Operation was cancelled");
}
try { _connectWaitOnLogin2.Wait(cancelToken); } //Waiting on READY handler
catch (OperationCanceledException) { return; }


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

@@ -58,7 +58,7 @@ namespace Discord
protected override void OnConnect()
{
_udp = new UdpClient(new IPEndPoint(IPAddress.Any, 0));
#if !DNX451
#if !DNX451 && !MONO
_udp.AllowNatTraversal(true);
#endif
_isReady = false;
@@ -132,7 +132,6 @@ namespace Discord
catch (OperationCanceledException) { }
catch (ObjectDisposedException) { }
catch (Exception ex) { DisconnectInternal(ex); }
finally { DisconnectInternal(); }
}

#if USE_THREAD
@@ -213,7 +212,6 @@ namespace Discord
catch (OperationCanceledException) { }
catch (ObjectDisposedException) { }
catch (Exception ex) { DisconnectInternal(ex); }
finally { DisconnectInternal(); }
}
#endif
//Closes the UDP socket when _disconnectToken is triggered, since UDPClient doesn't allow passing a canceltoken


+ 1
- 7
src/Discord.Net/DiscordWebSocket.cs View File

@@ -97,11 +97,7 @@ namespace Discord
try { await _task; } catch (NullReferenceException) { }
}
}

protected void DisconnectInternal()
{
_disconnectToken.Cancel();
}
protected void DisconnectInternal(Exception ex, bool isUnexpected = true)
{
if (_disconnectReason == null)
@@ -186,7 +182,6 @@ namespace Discord
}
catch (OperationCanceledException) { }
catch (Exception ex) { DisconnectInternal(ex); }
finally { DisconnectInternal(); }
}
private async Task SendAsync()
{
@@ -215,7 +210,6 @@ namespace Discord
}
catch (OperationCanceledException) { }
catch (Exception ex) { DisconnectInternal(ex); }
finally { DisconnectInternal(); }
}

protected abstract Task ProcessMessage(string json);


Loading…
Cancel
Save