From abe5db6e24ac86f3fe2cf995f676c6748004f3fa Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Fri, 3 Mar 2023 11:50:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=A9=E5=B1=95=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E5=87=8F=E5=B0=91=E4=BF=A1=E6=81=AF=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=97=B6=E7=9A=84if=E5=88=A4=E6=96=AD=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MsgTransmitTools/DataClass/BluetoothGateway.cs | 6 +----- .../ExtendLinkModel/HttpServer/HttpServerView.cs | 6 ++---- Assets/MsgTransmitTools/src/DataEventModel.cs | 13 ++++++++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Assets/MsgTransmitTools/DataClass/BluetoothGateway.cs b/Assets/MsgTransmitTools/DataClass/BluetoothGateway.cs index 6590d4a..daf0db6 100644 --- a/Assets/MsgTransmitTools/DataClass/BluetoothGateway.cs +++ b/Assets/MsgTransmitTools/DataClass/BluetoothGateway.cs @@ -5,7 +5,7 @@ using LitJson; using System; namespace JXSoft { - public class BluetoothGateway:IResponse + public struct BluetoothGateway:IResponse { /// /// @@ -34,10 +34,6 @@ namespace JXSoft { private string exceptionMsg; - public BluetoothGateway() { - - } - public string findDataByMac(string mac) { foreach (List deviceMsg in devices) { diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs b/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs index 6674ada..828f88a 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerView.cs @@ -24,10 +24,8 @@ namespace JXSoft { void Start() { this.httpServer = this.GetUtility(); - this.RegisterEvent(e => { - if (e.res.GetType() == typeof(BluetoothGateway)) { - // - } + this.RegisterMessageEvent(e => { + Debug.Log("收到消息:"+e.ip); }).UnRegisterWhenGameObjectDestroyed(gameObject); this.GetModel().onReceive(); } diff --git a/Assets/MsgTransmitTools/src/DataEventModel.cs b/Assets/MsgTransmitTools/src/DataEventModel.cs index 2b40965..903709d 100644 --- a/Assets/MsgTransmitTools/src/DataEventModel.cs +++ b/Assets/MsgTransmitTools/src/DataEventModel.cs @@ -228,9 +228,16 @@ namespace JXSoft { } #endregion - #region - public static class CanRegistMessageExtention { - + #region Extention + public static class CanRegistMessageExtention { + public static IUnRegister RegisterMessageEvent(this ICanRegisterEvent self, Action onEvent) + { + return self.GetArchitecture().RegisterEvent(e=> { + if (e.res.GetType() == typeof(TResponse)) { + onEvent.Invoke((TResponse)e.res); + } + }); + } } #endregion