From 58d94742b78a1b34d5e07f4f24e640765631f900 Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Fri, 3 Mar 2023 17:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E5=90=8D=E7=A7=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{UDPEventModel.cs => UDPClientModel.cs} | 2 +- ...entModel.cs.meta => UDPClientModel.cs.meta} | 0 .../ExtendLinkModel/UDPClient/UDPClientView.cs | 18 +++++++++--------- .../ExtendLinkModel/UDPClient/UDPPrinter.cs | 2 +- Assets/MsgTransmitTools/src/DataEventModel.cs | 4 +++- .../src/ProtocolSettingsModel.cs | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) rename Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/{UDPEventModel.cs => UDPClientModel.cs} (98%) rename Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/{UDPEventModel.cs.meta => UDPClientModel.cs.meta} (100%) diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPEventModel.cs b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs similarity index 98% rename from Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPEventModel.cs rename to Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs index b257e49..f3e357b 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPEventModel.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs @@ -4,7 +4,7 @@ using UnityEngine; using QFrameworkCP; namespace JXSoft { - public class UDPEventModel : DataEventModel + public class UDPClientModel : DataEventModel { private UDPLinkState udpState = UDPLinkState.NoIp; private string udpAddress = ""; diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPEventModel.cs.meta b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs.meta similarity index 100% rename from Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPEventModel.cs.meta rename to Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientModel.cs.meta diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientView.cs b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientView.cs index 128ac97..57af284 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientView.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPClientView.cs @@ -11,7 +11,7 @@ namespace JXSoft { protected override void Init() { this.RegisterUtility(new UDPUtility()); - this.RegisterModel(new UDPEventModel()); + this.RegisterModel(new UDPClientModel()); } } public class UDPClientView : MonoBehaviour, IController @@ -42,13 +42,13 @@ namespace JXSoft { if (e.state == UDPLinkState.Linking) { Debug.Log("UDP开始链接"); - this.GetModel().linkServer(); + this.GetModel().linkServer(); } if (e.state == UDPLinkState.LinkSucess) { Debug.Log("UDP链接成功"); - this.GetModel().onReceive(); - this.GetModel().sendRequest(new LinkUDPRequest(deviceId)); + this.GetModel().onReceive(); + this.GetModel().sendRequest(new LinkUDPRequest(deviceId)); onUDPLinkSuccess.Invoke(); } if (e.state == UDPLinkState.LinkFaild) @@ -63,25 +63,25 @@ namespace JXSoft { if (e.res.GetType() == typeof(LinkSuccessResponse)) { Debug.Log("Link Server success"); - this.GetModel().offReceive(); + this.GetModel().offReceive(); onServerConnected.Invoke(); } }); - this.GetModel().setLinkState((int)UDPLinkState.NoIp); - this.GetModel().setIP(UDPAddress, UDPPort); + this.GetModel().setLinkState((int)UDPLinkState.NoIp); + this.GetModel().setIP(UDPAddress, UDPPort); } public void restartUDPService() { onUDPReLink.Invoke(); - this.GetModel().closeServer(); + this.GetModel().closeServer(); StartCoroutine(waitTwoSecond()); } public IEnumerator waitTwoSecond() { yield return new WaitForSeconds(2.0f); - this.GetModel().setLinkState((int)UDPLinkState.Linking); + this.GetModel().setLinkState((int)UDPLinkState.Linking); } public IArchitecture GetArchitecture() { diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs index 9aec51d..d30ad7c 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/UDPClient/UDPPrinter.cs @@ -26,7 +26,7 @@ namespace JXSoft { { GameObject item = Instantiate(udpMsgItem, udpMsgContent); item.GetComponentInChildren().text = udpUtil.receivedData; - this.GetModel().onDataRecived.Invoke(udpUtil.receivedData); + this.GetModel().onDataRecived.Invoke(udpUtil.receivedData); } if (udpUtil.getTimeOutState() && udpUtil.isOpenUDP) diff --git a/Assets/MsgTransmitTools/src/DataEventModel.cs b/Assets/MsgTransmitTools/src/DataEventModel.cs index 305a1b9..1f754e2 100644 --- a/Assets/MsgTransmitTools/src/DataEventModel.cs +++ b/Assets/MsgTransmitTools/src/DataEventModel.cs @@ -70,13 +70,15 @@ namespace JXSoft { public abstract int getLinkState(); /// - /// Start a link & server, you can overwrite by you own fucntions + /// Start a link & server, you can override by you own fucntions /// /// is link success & server start success public virtual bool Start() { + setLinkState((int)LinkStateDefault.Open); return true; } public virtual bool Close() { + setLinkState((int)LinkStateDefault.Close); return true; } #endregion diff --git a/Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs b/Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs index a28dcb1..41ac532 100644 --- a/Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs +++ b/Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs @@ -19,7 +19,7 @@ namespace JXSoft { case (ProtocolType_.TCP): return this.GetModel(); case (ProtocolType_.UDP): - return this.GetModel(); + return this.GetModel(); default: return this.GetModel(); }