[Fix] Disconnecting socket client does not send close code (#2714)
* fix? * whoops, debugging stuff
This commit is contained in:
@@ -279,15 +279,17 @@ namespace Discord.API
|
||||
return;
|
||||
ConnectionState = ConnectionState.Disconnecting;
|
||||
|
||||
try
|
||||
{ _connectCancelToken?.Cancel(false); }
|
||||
catch { }
|
||||
|
||||
if (ex is GatewayReconnectException)
|
||||
await WebSocketClient.DisconnectAsync(4000).ConfigureAwait(false);
|
||||
else
|
||||
await WebSocketClient.DisconnectAsync().ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
_connectCancelToken?.Cancel(false);
|
||||
}
|
||||
catch { }
|
||||
|
||||
ConnectionState = ConnectionState.Disconnected;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,9 +110,6 @@ namespace Discord.Net.WebSockets
|
||||
{
|
||||
_isDisconnecting = true;
|
||||
|
||||
try
|
||||
{ _disconnectTokenSource.Cancel(false); }
|
||||
catch { }
|
||||
|
||||
if (_client != null)
|
||||
{
|
||||
@@ -120,11 +117,22 @@ namespace Discord.Net.WebSockets
|
||||
{
|
||||
var status = (WebSocketCloseStatus)closeCode;
|
||||
try
|
||||
{ await _client.CloseOutputAsync(status, "", new CancellationToken()); }
|
||||
{
|
||||
await _client.CloseOutputAsync(status, "", new CancellationToken());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
try
|
||||
{ _client.Dispose(); }
|
||||
{
|
||||
_client.Dispose();
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
_disconnectTokenSource.Cancel(false);
|
||||
}
|
||||
catch { }
|
||||
|
||||
_client = null;
|
||||
|
||||
Reference in New Issue
Block a user