更改了远程环境下websocket会来回发送重复消息的问题

This commit is contained in:
fengjiayi
2024-10-28 10:25:57 +08:00
parent e2f1ec5810
commit f20cfb755c
20 changed files with 297 additions and 167 deletions

View File

@@ -11,23 +11,28 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
/// <summary>
/// 消息处理上下文
/// </summary>
public class WebSocketMsgContext
public class WebSocketMsgContext : IDisposable
{
public WebSocketMsgContext(Func<string, Task> sendAsync)
{
this._sendAsync = sendAsync;
}
public void Dispose()
{
JsonObject = null;
MsgTheme = null;
MsgId = null;
MsgData = null;
MsgData = null;
_sendAsync = null;
}
/// <summary>
/// 标记是否已经处理,如果是,则提前退出
/// </summary>
public bool Handle { get; set; }
/// <summary>
/// 消息本体(文本)
/// </summary>
public string Msg { get; set; }
/// <summary>
/// 消息本体JObject
/// </summary>
@@ -107,6 +112,7 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
await SendAsync(msg);
}
}
}