Browse Source

Clean up state during disconnect better. Don't allow UDP disposed errors to trigger the DisconnectReason.

tags/docs-0.9
Brandon Smith 9 years ago
parent
commit
1236c85fba
3 changed files with 6 additions and 4 deletions
  1. +1
    -1
      src/Discord.Net/DiscordClient.cs
  2. +3
    -1
      src/Discord.Net/DiscordVoiceSocket.cs
  3. +2
    -2
      src/Discord.Net/DiscordWebSocket.cs

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

@@ -429,7 +429,7 @@ namespace Discord
{ {
_currentVoiceToken = data.Token; _currentVoiceToken = data.Token;
await _voiceWebSocket.ConnectAsync("wss://" + data.Endpoint.Split(':')[0]); await _voiceWebSocket.ConnectAsync("wss://" + data.Endpoint.Split(':')[0]);
await _voiceWebSocket.Login(_currentVoiceServerId, _myId, _myId, data.Token);
await _voiceWebSocket.Login(_currentVoiceServerId, _myId, _sessionId, data.Token);
} }
#endif #endif
} }


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

@@ -130,6 +130,7 @@ namespace Discord
} }
} }
catch (OperationCanceledException) { } catch (OperationCanceledException) { }
catch (ObjectDisposedException) { }
catch (Exception ex) { DisconnectInternal(ex); } catch (Exception ex) { DisconnectInternal(ex); }
finally { DisconnectInternal(); } finally { DisconnectInternal(); }
} }
@@ -210,6 +211,7 @@ namespace Discord
} }
} }
catch (OperationCanceledException) { } catch (OperationCanceledException) { }
catch (ObjectDisposedException) { }
catch (Exception ex) { DisconnectInternal(ex); } catch (Exception ex) { DisconnectInternal(ex); }
finally { DisconnectInternal(); } finally { DisconnectInternal(); }
} }
@@ -238,7 +240,7 @@ namespace Discord
var payload = (msg.Payload as JToken).ToObject<VoiceWebSocketEvents.Ready>(); var payload = (msg.Payload as JToken).ToObject<VoiceWebSocketEvents.Ready>();
_heartbeatInterval = payload.HeartbeatInterval; _heartbeatInterval = payload.HeartbeatInterval;
_ssrc = payload.SSRC; _ssrc = payload.SSRC;
_endpoint = new IPEndPoint((await Dns.GetHostAddressesAsync(_host)).FirstOrDefault(), payload.Port);
_endpoint = new IPEndPoint((await Dns.GetHostAddressesAsync(_host.Replace("wss://", ""))).FirstOrDefault(), payload.Port);
//_mode = payload.Modes.LastOrDefault(); //_mode = payload.Modes.LastOrDefault();
_mode = "plain"; _mode = "plain";
_udp.Connect(_endpoint); _udp.Connect(_endpoint);


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

@@ -78,13 +78,13 @@ namespace Discord
byte[] ignored; byte[] ignored;
while (_sendQueue.TryDequeue(out ignored)) { } while (_sendQueue.TryDequeue(out ignored)) { }


_disconnectReason = null;
_task = null;
if (_isConnected) if (_isConnected)
{ {
_isConnected = false; _isConnected = false;
RaiseDisconnected(wasUnexpected); RaiseDisconnected(wasUnexpected);
} }

_task = null;
}); });
} }
public Task ReconnectAsync() public Task ReconnectAsync()


Loading…
Cancel
Save