Browse Source

Ensure State is Connected before raising DiscordClient.Connected

tags/docs-0.9
RogueException 9 years ago
parent
commit
2f8754091e
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      src/Discord.Net/Net/WebSockets/WebSocket.cs

+ 6
- 3
src/Discord.Net/Net/WebSockets/WebSocket.cs View File

@@ -99,10 +99,10 @@ namespace Discord.Net.WebSockets
try try
{ {
State = ConnectionState.Connected; State = ConnectionState.Connected;

_connectedEvent.Set();
Logger.Info($"Connected"); Logger.Info($"Connected");

OnConnected(); OnConnected();
_connectedEvent.Set();
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -173,7 +173,10 @@ namespace Discord.Net.WebSockets
try try
{ {
if (!_connectedEvent.Wait(_client.Config.ConnectionTimeout, cancelToken)) if (!_connectedEvent.Wait(_client.Config.ConnectionTimeout, cancelToken))
throw new TimeoutException();
{
if (State != ConnectionState.Connected)
throw new TimeoutException();
}
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {


Loading…
Cancel
Save