Ensure socket is disconnected before reconnecting

This commit is contained in:
RogueException
2016-06-21 12:19:40 -03:00
parent 3e5193c3b7
commit 97078b557a

View File

@@ -163,6 +163,10 @@ namespace Discord
if (LoginState != LoginState.LoggedIn)
throw new InvalidOperationException("You must log in before connecting.");
var state = ConnectionState;
if (state == ConnectionState.Connecting || state == ConnectionState.Connected)
await DisconnectInternalAsync().ConfigureAwait(false);
ConnectionState = ConnectionState.Connecting;
await _gatewayLogger.InfoAsync("Connecting");
try