mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-02 15:50:47 +08:00
1. Serein.Proto.WebSocket项目中,ws方法入参新增了对于使用流程上下文作为参数的识别
This commit is contained in:
@@ -25,16 +25,7 @@ namespace Serein.Library.Utils
|
||||
/// <returns>对应的 Channel</returns>
|
||||
private Channel<TriggerResult<object>> GetOrCreateChannel(TSignal signal)
|
||||
{
|
||||
if(_channels.TryGetValue(signal, out var channel))
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
else
|
||||
{
|
||||
channel = Channel.CreateUnbounded<TriggerResult<object>>();
|
||||
_channels.AddOrUpdate(signal, _ => channel, (s, r) => channel = r);
|
||||
return channel;
|
||||
}
|
||||
return _channels.GetOrAdd(signal, _ => Channel.CreateUnbounded<TriggerResult<object>>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Serein.Library.Utils
|
||||
/// <summary>
|
||||
/// 消息ID生成工具
|
||||
/// </summary>
|
||||
public class MessageIdGenerator
|
||||
public class IdGeneratorHelper
|
||||
{
|
||||
private static readonly object _lock = new object();
|
||||
private static int _counter = 0;
|
||||
@@ -56,6 +56,11 @@ namespace Serein.Proto.WebSocket.Handle
|
||||
/// </summary>
|
||||
public bool[] UseMsgId { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用上下文作为参数
|
||||
/// </summary>
|
||||
public bool[] UseContent { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称
|
||||
/// </summary>
|
||||
|
||||
@@ -254,6 +254,12 @@ namespace Serein.Proto.WebSocket.Handle
|
||||
args[i] = data;
|
||||
}
|
||||
#endregion
|
||||
#region 传递上下文
|
||||
else if (config.UseContent[i])
|
||||
{
|
||||
args[i] = context;
|
||||
}
|
||||
#endregion
|
||||
#region 传递消息委托
|
||||
else if (config.IsNeedSendDelegate[i]) // 传递SendAsync委托
|
||||
{
|
||||
@@ -308,6 +314,7 @@ namespace Serein.Proto.WebSocket.Handle
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
if (!isCanInvoke)
|
||||
{
|
||||
|
||||
@@ -25,9 +25,5 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Library\Serein.Library.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -210,6 +210,7 @@ namespace Serein.Proto.WebSocket
|
||||
UseRequest = parameterInfos.Select(p => p.GetCustomAttribute<UseRequestAttribute>() is not null).ToArray(),// 是否使用整体data数据
|
||||
UseData = parameterInfos.Select(p => p.GetCustomAttribute<UseDataAttribute>() is not null).ToArray(), // 是否使用整体data数据
|
||||
UseMsgId = parameterInfos.Select(p => p.GetCustomAttribute<UseMsgIdAttribute>() is not null).ToArray(), // 是否使用消息ID
|
||||
UseContent = parameterInfos.Select(p => p.ParameterType.IsAssignableFrom(typeof(WebSocketHandleContext))).ToArray(), // 是否使用上下文
|
||||
IsNeedSendDelegate = temp_array.Select(p => p.IsNeedSend).ToArray(), // 是否需要发送消息的委托
|
||||
SendDelegateType = temp_array.Select(p => p.Type).ToArray(), // 发送消息的委托类型
|
||||
CachedSendDelegates = new Delegate[temp_array.Length], // 提前缓存发送委托数组
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<ProjectReference Include="..\Library\Serein.Library.csproj" />
|
||||
<ProjectReference Include="..\NodeFlow\Serein.NodeFlow.csproj" />
|
||||
<ProjectReference Include="..\Serein.Extend.NewtonsoftJson\Serein.Extend.NewtonsoftJson.csproj" />
|
||||
<ProjectReference Include="..\Serein.Proto.Modbus\Serein.Proto.Modbus.csproj" />
|
||||
<ProjectReference Include="..\Serein.Script\Serein.Script.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user