diff --git a/backend/Magic.Web.Core/Controller/Tcp/TcpServiceController.cs b/backend/Magic.Web.Core/Controller/Tcp/TcpServiceController.cs
index 217e4a839b4508674ac9e4c4c84fe24c5d1b18c1..cb380621d8e32142a71d09bf3b2f2be01c22596c 100644
--- a/backend/Magic.Web.Core/Controller/Tcp/TcpServiceController.cs
+++ b/backend/Magic.Web.Core/Controller/Tcp/TcpServiceController.cs
@@ -40,14 +40,14 @@ namespace Magic.Web.Core
///
///
[HttpPost]
- public void SendMessage(string id,[FromBody]string msg)
+ public async Task SendMessage(string id, [FromBody] string msg)
{
- if (!this.m_tcpService.TryGetSocketClient(id,out var socketClient))
+ if (!this.m_tcpService.TryGetClient(id, out var socketClient))
{
throw new Exception("没有找到对于Id的客户端");
}
- socketClient.Send(msg);
+ await socketClient.SendAsync(msg);
}
}
}
diff --git a/backend/Magic.Web.Core/Handlers/Tcp/TcpServicePlugin.cs b/backend/Magic.Web.Core/Handlers/Tcp/TcpServicePlugin.cs
index b45103a9f9b05339988179e8b6cb1ba053e55f7b..8b854606cdaf4e7a644d8fc3713e6a406e31bed2 100644
--- a/backend/Magic.Web.Core/Handlers/Tcp/TcpServicePlugin.cs
+++ b/backend/Magic.Web.Core/Handlers/Tcp/TcpServicePlugin.cs
@@ -18,24 +18,24 @@ namespace Magic.Web.Core.Handlers.Tcp
this.m_logger = logger;
}
- [GeneratorPlugin(nameof(ITcpConnectedPlugin.OnTcpConnected))]
- public async Task OnTcpConnected(ITcpClientBase client, ConnectedEventArgs e)
+ [GeneratorPlugin(typeof(ITcpConnectedPlugin))]
+ public async Task OnTcpConnected(ITcpSession client, ConnectedEventArgs e)
{
m_logger.LogInformation("Tcp客户端已连接。信息:{0}", client.GetIPPort());
await e.InvokeNext();
}
- [GeneratorPlugin(nameof(ITcpDisconnectedPlugin.OnTcpDisconnected))]
- public async Task OnTcpDisconnected(ITcpClientBase client, DisconnectEventArgs e)
+ [GeneratorPlugin(typeof(ITcpClosedPlugin))]
+ public async Task OnTcpClosed(ITcpSession client, ClosedEventArgs e)
{
- m_logger.LogInformation("Tcp客户端已断开。信息:{0},断开信息:{1}", client.GetIPPort(),e.Message);
+ m_logger.LogInformation("Tcp客户端已断开。信息:{0},断开信息:{1}", client.GetIPPort(), e.Message);
await e.InvokeNext();
}
- [GeneratorPlugin(nameof(ITcpReceivedPlugin.OnTcpReceived))]
- public async Task OnTcpReceived(ITcpClientBase client, ReceivedDataEventArgs e)
+ [GeneratorPlugin(typeof(ITcpReceivedPlugin))]
+ public async Task OnTcpReceived(ITcpSession client, ReceivedDataEventArgs e)
{
- m_logger.LogInformation("Tcp收到信息:{0}", Encoding.UTF8.GetString(e.ByteBlock.ToArray()));
+ m_logger.LogInformation("Tcp收到信息:{0}", e.ByteBlock.Span.ToString(Encoding.UTF8));
await e.InvokeNext();
}
}
diff --git a/backend/Magic.Web.Core/Magic.Web.Core.csproj b/backend/Magic.Web.Core/Magic.Web.Core.csproj
index 97fd524fb29d82e3639a2076d2d84150cccd2533..89ccc756cf5352c2f3109eaadb456858619e5017 100644
--- a/backend/Magic.Web.Core/Magic.Web.Core.csproj
+++ b/backend/Magic.Web.Core/Magic.Web.Core.csproj
@@ -27,11 +27,7 @@
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/backend/Magic.Web.Core/Magic.Web.Core.xml b/backend/Magic.Web.Core/Magic.Web.Core.xml
index 3f9b87830ae51e875d8a9d974b5edf6e076ebef8..9db7f26be051b1cbb07f9adce6bec4306258eba4 100644
--- a/backend/Magic.Web.Core/Magic.Web.Core.xml
+++ b/backend/Magic.Web.Core/Magic.Web.Core.xml
@@ -1576,21 +1576,137 @@
注册类型
实例类型
+
+
+ 标识源生成的实现。
+
+
+
+
+ 标识源生成成员的特性。
+
+
+
+
+ 生成行为。一般来说,对于非只读、非重写、且同时拥有get,set(可以私有)访问器的属性,会自动生成。
+ 对于字段,均不会自动生成。所以可以使用该设置,来指示生成器的生成行为。
+
+
使用源生成插件的调用。
-
+
使用源生成插件的调用。
- 插件名称,一般建议使用nameof()解决。
+ 插件名称,一般建议使用解决。
+
+
+
+ 标识该接口将使用源生成自动生成调用的代理类
+
+
+
+
+ 调用键的前缀,包括服务的命名空间,类名,不区分大小写。格式:命名空间.类名
+
+
+
+
+ 生成泛型方法的约束
+
+
+
+
+ 是否仅以函数名调用,当为True是,调用时仅需要传入方法名即可。
+
+
+
+
+ 生成代码的命名空间
+
+
+
+
+ 生成的类名,不要包含“I”,生成接口时会自动添加。
+
+
+
+
+ 生成代码
+
+
+
+
+ 继承接口
+
+
+
+
+ 代码生成标识
+
+
+
+
+ 生成扩展同步代码
+
+
+
+
+ 生成扩展异步代码
+
+
+
+
+ 生成实例类同步代码(源代码生成无效)
+
+
+
+
+ 生成实例类异步代码(源代码生成无效)
+
+
+
+
+ 生成接口同步代码
+
+
+
+
+ 生成接口异步代码
+
标识将通过源生成器生成Rpc服务的调用委托。
+
+
+ 标识将通过源生成器生成Rpc服务的注册代码。
+
+
+
+
+ 方法名称。默认是“RegisterAllFrom+AssemblyName”
+
+
+
+
+ 扩展类类名,默认是“RegisterRpcServerFrom+AssemblyName+Extension”
+
+
+
+
+ 访问修饰。
+
+ 如果为,将生成注册公共Rpc服务与非公共服务两个方法。其中非公共方法会在之前以Internal开头。
+ 如果为,将只生成注册非公共Rpc服务。
+ 如果为,将只生成注册公共Rpc服务。
+
+
+