From d927a6e95219022ba40313e5fc51e2224e6b51dd Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Tue, 28 Feb 2023 15:37:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TCPClient/Script/Source/TCPClientModel.cs | 20 +++++++++---------- .../TCPClient/Script/Source/TCPClientView.cs | 6 +++--- .../TCPServer/Script/TCPServerModel.cs | 7 ++++++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientModel.cs b/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientModel.cs index a549e27..45b87d3 100644 --- a/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientModel.cs +++ b/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientModel.cs @@ -21,13 +21,13 @@ namespace JXSoft { this.RegisterEvent(e=> { setLinkState((int)TCPLinkState.LinkTimeOut); - this.GetUtility().CloseTCPClient(); + this.GetUtility().CloseTCPClient(); }); //注册重写发送事件 this.RegisterEvent(e => { - if (this.GetUtility().isOpenTCP) + if (this.GetUtility().isOpenTCP) { - this.GetUtility().sendData(e.req.toProtocolData()); + this.GetUtility().sendData(e.req.toProtocolData()); } else { @@ -70,9 +70,9 @@ namespace JXSoft public void linkServer() { if (tcpState == TCPLinkState.Linking) { - if (!this.GetUtility().isOpenTCP) { + if (!this.GetUtility().isOpenTCP) { - bool isSuccess = this.GetUtility().StartTCPClient(tcpAddress, tcpPort); + bool isSuccess = this.GetUtility().StartTCPClient(tcpAddress, tcpPort); if (isSuccess) { setLinkState((int)TCPLinkState.LinkSucess); } @@ -90,10 +90,10 @@ namespace JXSoft { if (tcpState == TCPLinkState.LinkSucess) { - if (this.GetUtility().isOpenTCP) + if (this.GetUtility().isOpenTCP) { - this.GetUtility().CloseTCPClient(); + this.GetUtility().CloseTCPClient(); setLinkState((int)TCPLinkState.NoIp); } } @@ -126,7 +126,7 @@ namespace JXSoft #endregion #region util - public class TCPUtility : IUtility + public class TCPClientUtility : IUtility { public string tcpAddress; public int tcpPort; @@ -140,12 +140,12 @@ namespace JXSoft public Thread reciveT; public bool isTimeOut = false; - public TCPUtility() + public TCPClientUtility() { Debug.LogWarning("使用无参数构造tcp时,需要手动开启tcp服务"); } - public TCPUtility(string tcpAddress, int tcpPort) + public TCPClientUtility(string tcpAddress, int tcpPort) { this.tcpAddress = tcpAddress; this.tcpPort = tcpPort; diff --git a/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientView.cs b/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientView.cs index 9d61bc7..c046c84 100644 --- a/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientView.cs +++ b/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPClientView.cs @@ -13,14 +13,14 @@ namespace JXSoft { { protected override void Init() { - this.RegisterUtility(new TCPUtility()); + this.RegisterUtility(new TCPClientUtility()); this.RegisterModel(new TCPClientModel()); } } public class TCPClientView : MonoBehaviour,IController,ICanRegisterEvent { //Printer&MsgGetter - private TCPUtility tcpUtil; + private TCPClientUtility tcpUtil; public Transform tcpMsgContent; public GameObject tcpMsgItem; @@ -38,7 +38,7 @@ namespace JXSoft { { initTCPService(); DontDestroyOnLoad(this); - tcpUtil = GetArchitecture().GetUtility(); + tcpUtil = GetArchitecture().GetUtility(); } public void initTCPService() { diff --git a/Assets/MsgTransmitTools/TCPServer/Script/TCPServerModel.cs b/Assets/MsgTransmitTools/TCPServer/Script/TCPServerModel.cs index 6d6af28..3970e9a 100644 --- a/Assets/MsgTransmitTools/TCPServer/Script/TCPServerModel.cs +++ b/Assets/MsgTransmitTools/TCPServer/Script/TCPServerModel.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; namespace JXSoft { - public class TCPServerEventModel:DataEventModel + public class TCPServerModel:DataEventModel { public override void setLinkState(int linkState) @@ -20,5 +20,10 @@ namespace JXSoft { } } + + public class TCPServer { + + } + }