From 43b0d5870d528f23ecd6aeceb6cfd4325188b46f Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 01 七月 2021 15:50:43 +0800
Subject: [PATCH] Revert "1"

---
 HDL_ON/DAL/DriverLayer/Control_TcpClient.cs |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs b/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
index 01f3832..aa8aeff 100644
--- a/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
+++ b/HDL_ON/DAL/DriverLayer/Control_TcpClient.cs
@@ -7,10 +7,6 @@
 {
     public class Control_TcpClient
     {
-        /// <summary>
-        /// 閫氳ID
-        /// </summary>
-        public const int msg_id = 1;
 
         //澹版槑IP锛岀鍙o紝鍜屼竴涓敤鏉ヨ繛鎺ョ殑Socket
         public string _ip;
@@ -41,10 +37,11 @@
             {
                 _tcpClient.Connect(IPAddress.Parse(_ip), _port);
                 Task.Run(new Action(ReceiveMessage));//寮�鍚嚎绋嬶紝涓嶅仠鎺ユ敹娑堟伅
+                MainPage.Log($"鎵撳紑tcp client{_ip}:{_port}");
             }
             catch (Exception e)
             {
-                Console.WriteLine(e);
+                MainPage.Log(e.Message);
                 throw;
             }
             return true;//杩斿洖杩炴帴鐘舵��
@@ -69,7 +66,11 @@
         public void SendMessage(byte[] bytes)
         {
             NetworkStream networkStream = _tcpClient.GetStream();
-            networkStream.Write(bytes, 0, bytes.Length);
+            if (networkStream.CanWrite)
+            {
+                networkStream.Write(bytes, 0, bytes.Length);
+            }
+            //networkStream.Close();
         }
 
         /// <summary>
@@ -127,18 +128,7 @@
 
             }
         }
-        #region A鍗忚
-        /// <summary>
-        /// 鍙戦�丄鍗忚鏁版嵁
-        /// </summary>
-        /// <param name="topic"></param>
-        public void SendData(string topic)
-        {
-            string topicString = "Topic:" + topic + "/r/n";
-            string lenghtString = "Length:" + "/r/n" + "/r/n";
-        }
 
-        #endregion
 
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0