Clean up state during disconnect better. Don't allow UDP disposed errors to trigger the DisconnectReason.
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user