重新设计了Libray.Json Api以及 WebSocket 的交互处理方式

This commit is contained in:
fengjiayi
2025-08-02 10:48:31 +08:00
parent 1bccccc835
commit 6fc57458a7
29 changed files with 883 additions and 348 deletions

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Proto.WebSocket.Attributes
{
/// <summary>
/// 指示需要发送消息的处理方法
/// </summary>
public sealed class SendAttribute : Attribute
{
}
}

View File

@@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace Serein.Proto.WebSocket.Attributes
{
internal sealed class UseRequestAttribute : Attribute
/// <summary>
/// 指示使用 WebSocket 中请求的整体数据
/// </summary>
public sealed class UseRequestAttribute : Attribute
{
}
}

View File

@@ -1,8 +1,8 @@
namespace Serein.Proto.WebSocket.Attributes
{
/// <summary>
/// <para>标记该类是处理模板需要获取WebSocketServer/WebSocketClient了实例后使用(Server/Client).MsgHandleHelper.AddModule()进行添加。</para>
/// <para>处理模板需要继承 ISocketHandleModule 接口否则WebSocket接受到数据时,将无法进行调用相应的处理模板。</para>
/// <para>标记该类是处理模板</para>
/// <para>处理模板需要继承 ISocketHandleModule 接口,否则接受到 WebSocket 数据时,将无法进行调用相应的处理模板。</para>
/// <para>使用方式:</para>
/// <para>[AutoSocketModule(ThemeKey = "theme", DataKey = "data")]</para>
/// <para>public class PlcSocketService : ISocketHandleModule</para>
@@ -16,7 +16,7 @@
/// <para></para>
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public sealed class AutoSocketModuleAttribute : Attribute
public sealed class WebSocketModuleAttribute : Attribute
{
/// <summary>
/// 业务标识

View File

@@ -16,7 +16,7 @@
/// <para>Func&lt;dynamic,Task&gt; : 会自动将对象解析为Json字符串异步发送文本内容。</para>
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class AutoSocketHandleAttribute : Attribute
public sealed class WsMethodAttribute : Attribute
{
/// <summary>
/// 描述Json业务字段如果不设置将默认使用方法名称。
@@ -32,12 +32,6 @@
/// <para>会进行异步等待当Task结束后自动获取TResult进行发送请避免Task&lt;Task&lt;TResult&gt;&gt;诸如此类的Task泛型嵌套</para>
/// </summary>
public bool IsReturnValue = true;
/// <summary>
/// <para>表示该方法所有入参不能为空所需的参数在请求Json的Data不存在</para>
/// <para>若有一个参数无法从data获取则不会进行调用该方法</para>
/// <para>如果设置该属性为 false ,但某些入参不能为空,而不希望在代码中进行检查,请为入参添加[NotNull]/[Needful]特性</para>
/// </summary>
public bool ArgNotNull = true;
}