mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-22 17:16:34 +08:00
优化了节点连接
This commit is contained in:
@@ -123,7 +123,10 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"error in ws : {ex.Message}{Environment.NewLine}json value:{jsonObject}");
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
context.Handle = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
|
||||
/// <summary>
|
||||
/// 消息处理上下文
|
||||
/// </summary>
|
||||
public class WebSocketMsgContext : IDisposable
|
||||
public class WebSocketMsgContext /*: IDisposable*/
|
||||
{
|
||||
public WebSocketMsgContext(Func<string, Task> sendAsync)
|
||||
{
|
||||
@@ -31,7 +31,14 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
|
||||
/// <summary>
|
||||
/// 标记是否已经处理,如果是,则提前退出
|
||||
/// </summary>
|
||||
public bool Handle { get; set; }
|
||||
public bool Handle { get => _handle; set{
|
||||
if(value)
|
||||
{
|
||||
Dispose();
|
||||
_handle = value;
|
||||
}
|
||||
} }
|
||||
public bool _handle = false;
|
||||
|
||||
/// <summary>
|
||||
/// 消息本体(JObject)
|
||||
|
||||
@@ -201,13 +201,18 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
|
||||
/// </summary>
|
||||
/// <param name="context">此次请求的上下文</param>
|
||||
/// <returns></returns>
|
||||
public async Task HandleAsync(WebSocketMsgContext context)
|
||||
public void Handle(WebSocketMsgContext context)
|
||||
{
|
||||
foreach (var module in MyHandleModuleDict.Values)
|
||||
{
|
||||
await module.HandleAsync(context);
|
||||
if (context.Handle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_ = module.HandleAsync(context);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user