[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;
|
return;
|
||||||
ConnectionState = ConnectionState.Disconnecting;
|
ConnectionState = ConnectionState.Disconnecting;
|
||||||
|
|
||||||
try
|
|
||||||
{ _connectCancelToken?.Cancel(false); }
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
if (ex is GatewayReconnectException)
|
if (ex is GatewayReconnectException)
|
||||||
await WebSocketClient.DisconnectAsync(4000).ConfigureAwait(false);
|
await WebSocketClient.DisconnectAsync(4000).ConfigureAwait(false);
|
||||||
else
|
else
|
||||||
await WebSocketClient.DisconnectAsync().ConfigureAwait(false);
|
await WebSocketClient.DisconnectAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_connectCancelToken?.Cancel(false);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
ConnectionState = ConnectionState.Disconnected;
|
ConnectionState = ConnectionState.Disconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,9 +110,6 @@ namespace Discord.Net.WebSockets
|
|||||||
{
|
{
|
||||||
_isDisconnecting = true;
|
_isDisconnecting = true;
|
||||||
|
|
||||||
try
|
|
||||||
{ _disconnectTokenSource.Cancel(false); }
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
if (_client != null)
|
if (_client != null)
|
||||||
{
|
{
|
||||||
@@ -120,11 +117,22 @@ namespace Discord.Net.WebSockets
|
|||||||
{
|
{
|
||||||
var status = (WebSocketCloseStatus)closeCode;
|
var status = (WebSocketCloseStatus)closeCode;
|
||||||
try
|
try
|
||||||
{ await _client.CloseOutputAsync(status, "", new CancellationToken()); }
|
{
|
||||||
|
await _client.CloseOutputAsync(status, "", new CancellationToken());
|
||||||
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{ _client.Dispose(); }
|
{
|
||||||
|
_client.Dispose();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_disconnectTokenSource.Cancel(false);
|
||||||
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
_client = null;
|
_client = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user