mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 16:20:48 +08:00
更改了远程环境下websocket会来回发送重复消息的问题
This commit is contained in:
@@ -234,7 +234,10 @@ namespace Serein.Library.Network.WebSocketCommunication
|
||||
MsgQueueUtil msgQueueUtil,
|
||||
WebSocketAuthorizedHelper authorizedHelper)
|
||||
{
|
||||
|
||||
async Task sendasync(string text)
|
||||
{
|
||||
await SocketExtension.SendAsync(webSocket, text); // 回复客户端,处理方法中入参如果需要发送消息委托,则将该回调方法作为委托参数传入
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
var message = await msgQueueUtil.WaitMsgAsync(); // 有消息时通知
|
||||
@@ -251,16 +254,16 @@ namespace Serein.Library.Network.WebSocketCommunication
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_ = Task.Run(() => {
|
||||
JObject json = JObject.Parse(message);
|
||||
WebSocketMsgContext context = new WebSocketMsgContext(async (text) =>
|
||||
{
|
||||
await SocketExtension.SendAsync(webSocket, text); // 回复客户端,处理方法中入参如果需要发送消息委托,则将该回调方法作为委托参数传入
|
||||
});
|
||||
context.JsonObject = json;
|
||||
MsgHandleHelper.HandleMsg(context); // 处理消息
|
||||
});
|
||||
|
||||
using (var context = new WebSocketMsgContext(sendasync))
|
||||
{
|
||||
context.JsonObject = JObject.Parse(message);
|
||||
await MsgHandleHelper.HandleAsync(context); // 处理消息
|
||||
}
|
||||
//_ = Task.Run(() => {
|
||||
|
||||
|
||||
//});
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user