From 71e374cfc9b6d31b4bef007042d367bb3fc44ee8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-B25GA9E\\W35" <1733709035@qq.com> Date: Tue, 14 Mar 2023 17:21:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=85=B3=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/JsonGenerate/JsonFileLoaderEditor.cs | 9 ++++- .../Example/Scenes/TCPLinkExample.unity | 40 +++++++++++++++++++ .../Example/Script/TCPClientExample.cs | 5 +-- .../HttpServer/HttpServerModel.cs | 2 +- .../TCPClient/Script/TCPClientModel.cs | 20 ++++++---- .../TCPClient/Script/TCPClientView.cs | 6 +-- 6 files changed, 65 insertions(+), 17 deletions(-) diff --git a/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs b/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs index 5b942e4..695956f 100644 --- a/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs +++ b/Assets/DataGenerateTools/src/JsonGenerate/JsonFileLoaderEditor.cs @@ -38,8 +38,9 @@ namespace JXSoft { keyValuePairs.Clear(); } if (JsonFile != null) { - reader = new JsonReader(JsonFile.text); /* + reader = new JsonReader(JsonFile.text); + while (reader.Read()) { string type = reader.Value != null ? reader.Value.GetType().ToString() : ""; @@ -49,9 +50,13 @@ namespace JXSoft { EditorGUILayout.TextField("Token", reader.Token.ToString()); EditorGUILayout.TextField("Value", value); EditorGUILayout.EndHorizontal(); - }*/ + } + */ } } + public void loadDataFromJson() { + + } } } diff --git a/Assets/MsgTransmitTools/Example/Scenes/TCPLinkExample.unity b/Assets/MsgTransmitTools/Example/Scenes/TCPLinkExample.unity index 5adf653..ca390f5 100644 --- a/Assets/MsgTransmitTools/Example/Scenes/TCPLinkExample.unity +++ b/Assets/MsgTransmitTools/Example/Scenes/TCPLinkExample.unity @@ -128,6 +128,16 @@ 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: 1515527918816451327, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} propertyPath: m_AnchorMax.x @@ -138,6 +148,16 @@ 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 @@ -248,6 +268,26 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 1515527919511105903, guid: 27bf485803eb75f4598b17afdfac3cfa, + type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1515527919511105903, guid: 27bf485803eb75f4598b17afdfac3cfa, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1515527919511105903, guid: 27bf485803eb75f4598b17afdfac3cfa, + type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1515527919511105903, guid: 27bf485803eb75f4598b17afdfac3cfa, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 1515527919516098611, guid: 27bf485803eb75f4598b17afdfac3cfa, type: 3} propertyPath: m_AnchorMax.x diff --git a/Assets/MsgTransmitTools/Example/Script/TCPClientExample.cs b/Assets/MsgTransmitTools/Example/Script/TCPClientExample.cs index 0038a78..15fbc5c 100644 --- a/Assets/MsgTransmitTools/Example/Script/TCPClientExample.cs +++ b/Assets/MsgTransmitTools/Example/Script/TCPClientExample.cs @@ -31,8 +31,7 @@ public class YourResponse : AbstractJsonResponse } public struct YourNumberFilterResponse : IResponse { - public string code; - private int codeNum; + public int codeNum; private string exceptionMsg; public string toProtocolData() { @@ -41,7 +40,7 @@ public struct YourNumberFilterResponse : IResponse public bool trySetData(string protocolData) { - bool isNumber = int.TryParse(code, out codeNum); + bool isNumber = int.TryParse(protocolData, out codeNum); if (!isNumber) { exceptionMsg = "这不是数字"; diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerModel.cs b/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerModel.cs index 2c862c5..9d5adb8 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerModel.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/HttpServer/HttpServerModel.cs @@ -37,7 +37,7 @@ namespace JXSoft { { this.GetUtility().closeServer(); setLinkState((int)LinkStateDefault.Close); - return base.Close(); + return true; } public void setPrefixes(string[] prefixes) { diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/TCPClient/Script/TCPClientModel.cs b/Assets/MsgTransmitTools/ExtendLinkModel/TCPClient/Script/TCPClientModel.cs index 1d287c3..b7a4614 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/TCPClient/Script/TCPClientModel.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/TCPClient/Script/TCPClientModel.cs @@ -66,26 +66,32 @@ namespace JXSoft /// /// 与服务端建立链接 /// - public void linkServer() { + public override bool Start() + { if (tcpState == TCPLinkState.Linking) { - if (!this.GetUtility().isOpenTCP) { - + if (!this.GetUtility().isOpenTCP) + { + bool isSuccess = this.GetUtility().StartTCPClient(tcpAddress, tcpPort); - if (isSuccess) { + if (isSuccess) + { setLinkState((int)TCPLinkState.LinkSucess); + return true; } else { setLinkState((int)TCPLinkState.LinkFaild); + return false; } } } + return false; } /// /// 与服务端断开链接 /// - public void closeServer() + public override bool Close() { if (tcpState == TCPLinkState.LinkSucess) { @@ -94,11 +100,11 @@ namespace JXSoft this.GetUtility().CloseTCPClient(); setLinkState((int)TCPLinkState.NoIp); + return true; } } + return false; } - - } #region enum diff --git a/Assets/MsgTransmitTools/ExtendLinkModel/TCPClient/Script/TCPClientView.cs b/Assets/MsgTransmitTools/ExtendLinkModel/TCPClient/Script/TCPClientView.cs index a0cfbd5..98dc24a 100644 --- a/Assets/MsgTransmitTools/ExtendLinkModel/TCPClient/Script/TCPClientView.cs +++ b/Assets/MsgTransmitTools/ExtendLinkModel/TCPClient/Script/TCPClientView.cs @@ -29,8 +29,6 @@ namespace JXSoft { public UnityEvent onTCPLinkFaild; public UnityEvent onServerConnected; public UnityEvent onTCPReLink; - - private int deviceId; // Start is called before the first frame update void Awake() @@ -46,7 +44,7 @@ namespace JXSoft { this.RegisterLinkStateEvent((int)TCPLinkState.Linking, () => { Debug.Log("TCPʼ"); - this.GetModel().linkServer(); + this.GetModel().Start(); }); this.RegisterLinkStateEvent((int)TCPLinkState.LinkSucess, () => { @@ -65,7 +63,7 @@ namespace JXSoft { public void restartTCPService() { onTCPReLink.Invoke(); - this.GetModel().closeServer(); + this.GetModel().Close(); StartCoroutine(waitTwoSecond()); } public IEnumerator waitTwoSecond() {