From 78e1e9dad7a72784845c91aec073b40e339d59d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=BA=E8=83=BD=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Wed, 26 Jun 2024 21:36:03 +0800 Subject: [PATCH] =?UTF-8?q?ClientBase=E5=B7=A5=E4=BD=9C=E4=BA=8ERPC?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=97=B6=EF=BC=8C=E6=94=AF=E6=8C=81=E4=B8=8B?= =?UTF-8?q?=E8=A1=8C=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NewLife.Remoting/Clients/ClientBase.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/NewLife.Remoting/Clients/ClientBase.cs b/NewLife.Remoting/Clients/ClientBase.cs index cea3fd5..50bdf29 100644 --- a/NewLife.Remoting/Clients/ClientBase.cs +++ b/NewLife.Remoting/Clients/ClientBase.cs @@ -183,7 +183,23 @@ protected virtual void OnInit() /// 创建RPC客户端 /// /// - protected virtual ApiClient CreateRpc(String urls) => new MyApiClient { Client = this, Servers = urls.Split(","), Log = Log }; + protected virtual ApiClient CreateRpc(String urls) + { + var client = new MyApiClient { Client = this, Servers = urls.Split(","), Log = Log }; + client.Received += (s, e) => + { + var msg = e.Message; + var api = e.ApiMessage; + if (msg != null && !msg.Reply && api != null && api.Action == "Notify") + { + var cmd = api.Data?.ToStr().ToJsonEntity(); + if (cmd != null) + _ = ReceiveCommand(cmd, client.Local?.Type + ""); + } + }; + + return client; + } class MyApiClient : ApiClient {