From e1b54648fea41896eba2378ab9860a5018dffcce Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Sat, 18 Feb 2023 16:57:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=85=B3=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Example/Scenes/TCPLinkExample.unity | 126 ++++++------------ .../TCPClient/Prefeb/TCPPrinter.prefab | 21 +-- .../TCPClient/Script/Source/TCPEventModel.cs | 28 +++- .../TCPClient/Script/View/TCPClientView.cs | 36 ++++- .../TCPClient/Script/View/TCPPrinter.cs | 48 ------- .../TCPClient/Script/View/TCPPrinter.cs.meta | 11 -- .../UDPClient/UDPClientView.cs | 2 +- .../UDPClient/UDPEventModel.cs | 2 +- Assets/MsgTransmitTools/src/DataEventModel.cs | 59 ++++++-- .../src/ProtocolSettingsModel.cs | 3 +- 10 files changed, 153 insertions(+), 183 deletions(-) delete mode 100644 Assets/MsgTransmitTools/TCPClient/Script/View/TCPPrinter.cs delete mode 100644 Assets/MsgTransmitTools/TCPClient/Script/View/TCPPrinter.cs.meta diff --git a/Assets/MsgTransmitTools/TCPClient/Example/Scenes/TCPLinkExample.unity b/Assets/MsgTransmitTools/TCPClient/Example/Scenes/TCPLinkExample.unity index 623857e..7bf2793 100644 --- a/Assets/MsgTransmitTools/TCPClient/Example/Scenes/TCPLinkExample.unity +++ b/Assets/MsgTransmitTools/TCPClient/Example/Scenes/TCPLinkExample.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -510,26 +510,6 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 1205360335} m_Modifications: - - target: {fileID: 1515527917566557997, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_AnchorMax.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1515527917566557997, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1515527918183730452, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_IsActive - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1515527918760088269, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_Text - value: - objectReference: {fileID: 0} - target: {fileID: 1515527918816451327, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} propertyPath: m_AnchorMax.x @@ -540,16 +520,6 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 1515527918842651468, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1515527918842651468, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - target: {fileID: 1515527919082889016, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} propertyPath: m_Name @@ -557,127 +527,107 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalPosition.x - value: 0 + propertyPath: m_Pivot.x + value: 0.5 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalPosition.y - value: 0 + propertyPath: m_Pivot.y + value: 0.5 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalPosition.z + propertyPath: m_RootOrder value: 0 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_LocalRotation.y - value: -0 + propertyPath: m_AnchorMax.x + value: 0.5 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalRotation.z - value: -0 + propertyPath: m_AnchorMax.y + value: 0.5 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalRotation.w - value: 1 + propertyPath: m_AnchorMin.x + value: 0.5 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_RootOrder - value: 0 + propertyPath: m_AnchorMin.y + value: 0.5 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 + propertyPath: m_SizeDelta.x + value: 1280 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 + propertyPath: m_SizeDelta.y + value: 720 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_LocalEulerAnglesHint.z + propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_AnchoredPosition.x + propertyPath: m_LocalPosition.y value: 0 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_AnchoredPosition.y + propertyPath: m_LocalPosition.z value: 0 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_SizeDelta.x - value: 1280 - objectReference: {fileID: 0} - - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_SizeDelta.y - value: 720 - objectReference: {fileID: 0} - - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_AnchorMin.x - value: 0.5 + propertyPath: m_LocalRotation.w + value: 1 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_AnchorMin.y - value: 0.5 + propertyPath: m_LocalRotation.x + value: -0 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_AnchorMax.x - value: 0.5 + propertyPath: m_LocalRotation.y + value: -0 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_AnchorMax.y - value: 0.5 + propertyPath: m_LocalRotation.z + value: -0 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_Pivot.x - value: 0.5 + propertyPath: m_AnchoredPosition.x + value: 0 objectReference: {fileID: 0} - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_Pivot.y - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 1515527919511105903, guid: 27bf485803eb75f4598b17afdfac3cfa, - type: 3} - propertyPath: m_AnchorMax.x + propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 1515527919511105903, guid: 27bf485803eb75f4598b17afdfac3cfa, + - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_AnchorMax.y + propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 1515527919511105903, guid: 27bf485803eb75f4598b17afdfac3cfa, + - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_SizeDelta.x + propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 1515527919511105903, guid: 27bf485803eb75f4598b17afdfac3cfa, + - target: {fileID: 1515527919082889017, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} - propertyPath: m_SizeDelta.y + propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - target: {fileID: 1515527919516098611, guid: 27bf485803eb75f4598b17afdfac3cfa, diff --git a/Assets/MsgTransmitTools/TCPClient/Prefeb/TCPPrinter.prefab b/Assets/MsgTransmitTools/TCPClient/Prefeb/TCPPrinter.prefab index cd4d784..43b01ba 100644 --- a/Assets/MsgTransmitTools/TCPClient/Prefeb/TCPPrinter.prefab +++ b/Assets/MsgTransmitTools/TCPClient/Prefeb/TCPPrinter.prefab @@ -500,7 +500,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Button + m_Text: --- !u!1 &1515527918816451326 GameObject: m_ObjectHideFlags: 0 @@ -785,7 +785,6 @@ GameObject: m_Component: - component: {fileID: 1515527919082889017} - component: {fileID: 1515527919082889015} - - component: {fileID: 1515527919082889014} m_Layer: 5 m_Name: TCPPrinter m_TagString: Untagged @@ -800,7 +799,7 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1515527919082889016} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: @@ -826,6 +825,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 558c5409545c2634d92e208d8852c9ea, type: 3} m_Name: m_EditorClassIdentifier: + tcpMsgContent: {fileID: 1515527919033040842} + tcpMsgItem: {fileID: 1515527918183730452} onRecievedOpenDevice: m_PersistentCalls: m_Calls: [] @@ -841,20 +842,6 @@ MonoBehaviour: onTCPReLink: m_PersistentCalls: m_Calls: [] ---- !u!114 &1515527919082889014 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1515527919082889016} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d9e452279efa30b4d9c01036c54a6c75, type: 3} - m_Name: - m_EditorClassIdentifier: - tcpMsgContent: {fileID: 1515527919033040842} - tcpMsgItem: {fileID: 1515527918183730452} --- !u!1 &1515527919511105902 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPEventModel.cs b/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPEventModel.cs index a599395..2b0a775 100644 --- a/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPEventModel.cs +++ b/Assets/MsgTransmitTools/TCPClient/Script/Source/TCPEventModel.cs @@ -5,6 +5,7 @@ using System.Text; using System.Net.Sockets; using System.Threading; using System.Net.NetworkInformation; +using System.Text.RegularExpressions; namespace JXSoft { @@ -25,7 +26,7 @@ namespace JXSoft this.RegisterEvent(e => { if (this.GetUtility().isOpenTCP) { - this.GetUtility().sendData(e.req.toJson()); + this.GetUtility().sendData(e.req.toProtocolData()); } else { @@ -52,9 +53,15 @@ namespace JXSoft public void setIP(string ip,int port) { this.tcpAddress = ip; this.tcpPort = port; - //此处可以加ip校验 - Debug.LogWarning("此处未进行ip以及端口号校验,日后有需求可以增加"); - setLinkState((int)TCPLinkState.Linking); + string patten = @"(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; + //ip校验 + if (Regex.IsMatch(ip, patten) && port < 65535) + { + setLinkState((int)TCPLinkState.Linking); + } + else { + Debug.LogWarning("ip格式错误"); + } } /// /// 与服务端建立链接 @@ -103,6 +110,19 @@ namespace JXSoft LinkSucess = 3, LinkTimeOut = 4 } + + public class TCPLinkStateManage : ILinkState{ + private TCPLinkState tcpState = TCPLinkState.NoIp; + public int getLinkState() + { + return (int)tcpState; + } + + public bool invoke(int invokeState) + { + throw new NotImplementedException(); + } + } #endregion #region event diff --git a/Assets/MsgTransmitTools/TCPClient/Script/View/TCPClientView.cs b/Assets/MsgTransmitTools/TCPClient/Script/View/TCPClientView.cs index 3a79624..e14ba6e 100644 --- a/Assets/MsgTransmitTools/TCPClient/Script/View/TCPClientView.cs +++ b/Assets/MsgTransmitTools/TCPClient/Script/View/TCPClientView.cs @@ -5,7 +5,8 @@ using UnityEngine.Events; using QFrameworkCP; using JXSoft; using System; - +using System.Threading; +using UnityEngine.UI; namespace JXSoft { public class TCPMangerArchitecture : Architecture @@ -18,6 +19,11 @@ namespace JXSoft { } public class TCPClientView : MonoBehaviour,IController,ICanRegisterEvent { + //Printer&MsgGetter + private TCPUtility tcpUtil; + public Transform tcpMsgContent; + public GameObject tcpMsgItem; + public UnityEvent onRecievedOpenDevice; public UnityEvent onTCPLinkSuccess; public UnityEvent onTCPLinkFaild; @@ -32,6 +38,7 @@ namespace JXSoft { { initTCPService(); DontDestroyOnLoad(this); + tcpUtil = GetArchitecture().GetUtility(); } public void initTCPService() { @@ -82,6 +89,31 @@ namespace JXSoft { yield return new WaitForSeconds(2.0f); this.GetModel().setLinkState((int)TCPLinkState.Linking); } + + // Update is called once per frame + void Update() + { + //Debug.Log(tcpUtil.Read_TCPClient()); + if (tcpUtil != null && !"".Equals(tcpUtil.getReceivedValue())) + { + GameObject item = Instantiate(tcpMsgItem, tcpMsgContent); + item.GetComponentInChildren().text = tcpUtil.receivedData; + this.GetModel().onDataRecived.Invoke(tcpUtil.receivedData); + } + if (tcpUtil.getTimeOutState() && tcpUtil.isOpenTCP) + { + this.SendEvent(new onLinkException(tcpUtil.exceptionData)); + tcpUtil.isOpenTCP = false; + } + } + private void OnDestroy() + { + if (tcpUtil.reciveT != null && tcpUtil.reciveT.ThreadState == ThreadState.Running) + { + tcpUtil.reciveT.Abort(); + } + } + public IArchitecture GetArchitecture() { return TCPMangerArchitecture.Interface; @@ -106,7 +138,7 @@ namespace JXSoft { this.id = id.ToString(); this.type = 1; } - public string toJson() + public string toProtocolData() { return JsonUtility.ToJson(this); } diff --git a/Assets/MsgTransmitTools/TCPClient/Script/View/TCPPrinter.cs b/Assets/MsgTransmitTools/TCPClient/Script/View/TCPPrinter.cs deleted file mode 100644 index 7a81128..0000000 --- a/Assets/MsgTransmitTools/TCPClient/Script/View/TCPPrinter.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.Events; -using UnityEngine.UI; -using QFrameworkCP; -using System.Threading; - -namespace JXSoft -{ - public class TCPPrinter : MonoBehaviour,IController - { - private TCPUtility tcpUtil; - public Transform tcpMsgContent; - public GameObject tcpMsgItem; - - void Awake() - { - tcpUtil = GetArchitecture().GetUtility(); - } - - // Update is called once per frame - void Update() - { - //Debug.Log(tcpUtil.Read_TCPClient()); - if (tcpUtil != null && !"".Equals(tcpUtil.getReceivedValue())) { - GameObject item = Instantiate(tcpMsgItem, tcpMsgContent); - item.GetComponentInChildren().text = tcpUtil.receivedData; - this.GetModel().onDataRecived.Invoke(tcpUtil.receivedData); - } - if (tcpUtil.getTimeOutState() && tcpUtil.isOpenTCP) { - this.SendEvent(new onLinkException(tcpUtil.exceptionData)); - tcpUtil.isOpenTCP = false; - } - } - private void OnDestroy() - { - if (tcpUtil.reciveT != null && tcpUtil.reciveT.ThreadState == ThreadState.Running) { - tcpUtil.reciveT.Abort(); - } - } - public IArchitecture GetArchitecture() - { - return TCPMangerArchitecture.Interface; - } - - } -} diff --git a/Assets/MsgTransmitTools/TCPClient/Script/View/TCPPrinter.cs.meta b/Assets/MsgTransmitTools/TCPClient/Script/View/TCPPrinter.cs.meta deleted file mode 100644 index ed28c6f..0000000 --- a/Assets/MsgTransmitTools/TCPClient/Script/View/TCPPrinter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d9e452279efa30b4d9c01036c54a6c75 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/MsgTransmitTools/UDPClient/UDPClientView.cs b/Assets/MsgTransmitTools/UDPClient/UDPClientView.cs index f4197d2..2d61e79 100644 --- a/Assets/MsgTransmitTools/UDPClient/UDPClientView.cs +++ b/Assets/MsgTransmitTools/UDPClient/UDPClientView.cs @@ -99,7 +99,7 @@ namespace JXSoft { this.id = id.ToString(); this.type = 1; } - public string toJson() + public string toProtocolData() { return JsonUtility.ToJson(this); } diff --git a/Assets/MsgTransmitTools/UDPClient/UDPEventModel.cs b/Assets/MsgTransmitTools/UDPClient/UDPEventModel.cs index 7738a30..b257e49 100644 --- a/Assets/MsgTransmitTools/UDPClient/UDPEventModel.cs +++ b/Assets/MsgTransmitTools/UDPClient/UDPEventModel.cs @@ -19,7 +19,7 @@ namespace JXSoft { this.RegisterEvent(e => { if (this.GetUtility().isOpenUDP) { - this.GetUtility().sendData(e.req.toJson()); + this.GetUtility().sendData(e.req.toProtocolData()); } else { diff --git a/Assets/MsgTransmitTools/src/DataEventModel.cs b/Assets/MsgTransmitTools/src/DataEventModel.cs index e5da919..07229b2 100644 --- a/Assets/MsgTransmitTools/src/DataEventModel.cs +++ b/Assets/MsgTransmitTools/src/DataEventModel.cs @@ -10,10 +10,12 @@ namespace JXSoft { //任何通讯类围绕DataEventModel进行 public abstract class DataEventModel : AbstractModel { + //管理消息收发响应控制 public IOCContainer mCommandContainer = new IOCContainer(); + //管理连接状态响应 + public IOCContainer mLinkStateContainer = new IOCContainer(); public UnityStringEvent onDataRecived = new UnityStringEvent(); public Color printColor = Color.white; - private int linkStatus = 0; #region ReceiveFunctions public void sendResponseCommand(string json) where T : IResponse, new() @@ -63,14 +65,33 @@ namespace JXSoft { #endregion #region LinkStatusManage - public abstract void setLinkState(int linkStatus); + public abstract void setLinkState(int linkState); public abstract int getLinkState(); + public void invokeLinkState(int invokeState) where TLinkState : ILinkState ,new(){ + } + + public void invokeLinkState(TLinkState linkState,int invokeState) where TLinkState : ILinkState, new() + { + } + + public void registerLinkState(ILinkState linkState) { + mLinkStateContainer.Register(linkState); + } + //public abstract void nodifyLinkState() where TLinkState:ILinkState; //public abstract void registerLinkState(); #endregion } + #region enum + public enum LinkStateDefault { + NoLink = 0, + LinkSuccess = 1, + LinkFaild = 2 + } + #endregion + #region Command /// /// 处理响应数据,添加对应的Command进行处理,需要提前生成命令池 @@ -93,7 +114,7 @@ namespace JXSoft { bool isSet = response.trySetData(json); if (isSet) { - Debug.Log("Received:" + response.toJson() + response.GetType()); + Debug.Log("Received:" + response.toProtocolData() + response.GetType()); this.SendEvent(new ResponseMsgEvent(response)); } } @@ -128,24 +149,38 @@ namespace JXSoft { #region interface public interface IResponse { - string toJson(); /// - /// 尝试填充数据,如果json不合法,则返回false,忽略该条数据响应 + /// 此处用于截获接收到的数据,建议作为调试依据 /// - /// /// - bool trySetData(string json); + string toProtocolData(); + /// + /// 尝试填充数据,如果不符合相关协议规则,建议返回false,如果此处返回为false,则忽略该条数据响应。 + /// + /// 协议数据格式 + /// + bool trySetData(string protocolData); + /// + /// 如果接收到信息定性为异常信息,获取异常信息 + /// + /// 异常信息结果 string getException(); } public interface IRequest { - string toJson(); + //按照协议定义发送格式,转换为字符串发送 + string toProtocolData(); } + public interface ILinkState { - int getLinkStatus(); + //获取当前链接状态 + int getLinkState(); + //执行当前链接 + bool invoke(int invokeState); } + #endregion #region AbstractClass @@ -156,7 +191,7 @@ namespace JXSoft { public abstract class AbstractResponse : IResponse { private string exceptionMsg; - public virtual string toJson() + public virtual string toProtocolData() { return JsonUtility.ToJson(this, true); } @@ -180,6 +215,10 @@ namespace JXSoft { } #endregion + #region LinkState + + #endregion + #region event public struct ResponseMsgEvent { diff --git a/Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs b/Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs index 279f23c..3856756 100644 --- a/Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs +++ b/Assets/MsgTransmitTools/src/ProtocolSettingsModel.cs @@ -4,11 +4,12 @@ using UnityEngine; using QFrameworkCP; namespace JXSoft { - //通讯协议管理 + //通讯协议管理,目前仅做独立通讯,后续会增加多线通讯 public class ProtocolSettingsModel : AbstractModel, ICanGetModel { protected override void OnInit() { + } private ProtocolType protocolType = ProtocolType.NOPROTOCOL; public DataEventModel getProtocol()