Skip to content

Commit

Permalink
fix: 修复一个聚合错误#1
Browse files Browse the repository at this point in the history
  • Loading branch information
zkhssb committed Jul 12, 2023
1 parent 877c1b7 commit 840e288
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions QQChannelSharp/Client/WsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using QQChannelSharp.Extensions;
using QQChannelSharp.Logger;
using QQChannelSharp.WebSocket;
using System.Net.Sockets;
using System.Net.WebSockets;
using System.Text;
using System.Text.Json;
Expand Down Expand Up @@ -201,25 +202,24 @@ private async Task ListeningAsync()
}
await HandleMessageAsync(Encoding.UTF8.GetString(ms.ToArray()));
}
catch (WebSocketException ex)
{
Log.LogError("ws", ex.ToString());
if (null != Error)
await Error(_session, ex);

_errorCode = ex.ErrorCode;
break; // 跳出While
}
catch (TaskCanceledException)
{
break; // 任务已取消, 跳出While
}
catch (Exception ex)
{
Log.LogError("ws", ex.ToString());
if (ex is WebSocketException wsEx)
{
Log.LogError("ws", ex.ToString());
if (null != Error)
await Error(_session, wsEx);

_errorCode = wsEx.ErrorCode;
break;
}else if (ex is HttpRequestException or SocketException or TaskCanceledException)
{
break;
}
}
}
ClientClosed?.Invoke(_session, _errorCode, "None"); // 已取消 or 连接已断开但是不知道原因
ClientClosed?.Invoke(_session, _errorCode, string.Empty); // 已取消 or 连接已断开但是不知道原因
}

public Session Session()
Expand Down

0 comments on commit 840e288

Please sign in to comment.