Browse Source

扩展TCP通信客户端信息

yuzhengyang 5 years ago
parent
commit
594cde1e0a

+ 1 - 1
Azylee.Utils/Azylee.Core/IOUtils/TxtUtils/ConfigTool.cs

@@ -97,7 +97,7 @@ namespace Azylee.Core.IOUtils.TxtUtils
                 ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
                 ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
                 return true;
                 return true;
             }
             }
-            catch { return false; }
+            catch (Exception ex) { return false; }
         }
         }
         public static bool SetExe(string exePath, string key, string value)
         public static bool SetExe(string exePath, string key, string value)
         {
         {

+ 1 - 1
Azylee.Utils/Azylee.Jsons/Json.cs

@@ -108,7 +108,7 @@ namespace Azylee.Jsons
                 string s = Encoding.UTF8.GetString(b);
                 string s = Encoding.UTF8.GetString(b);
                 return JsonConvert.DeserializeObject<T>(s);
                 return JsonConvert.DeserializeObject<T>(s);
             }
             }
-            catch { return default(T); }
+            catch(Exception ex) { return default(T); }
         }
         }
     }
     }
 }
 }

+ 2 - 0
Azylee.Utils/Azylee.YeahWeb/Azylee.YeahWeb.csproj

@@ -55,6 +55,8 @@
     <Compile Include="EmailUtils\EmailTool.cs" />
     <Compile Include="EmailUtils\EmailTool.cs" />
     <Compile Include="ExtWebAPI\BingWebAPI\WallpaperUtils\WallpaperWebModel.cs" />
     <Compile Include="ExtWebAPI\BingWebAPI\WallpaperUtils\WallpaperWebModel.cs" />
     <Compile Include="ExtWebAPI\BingWebAPI\WallpaperUtils\WallpaperTool.cs" />
     <Compile Include="ExtWebAPI\BingWebAPI\WallpaperUtils\WallpaperTool.cs" />
+    <Compile Include="ExtWebAPI\IPAddressAPI\PublicIPAddressTool.cs" />
+    <Compile Include="ExtWebAPI\IPAddressAPI\PublicIPAddressModel.cs" />
     <Compile Include="FTPUtils\FTPTool.cs" />
     <Compile Include="FTPUtils\FTPTool.cs" />
     <Compile Include="HttpUtils\MethodUtils\ExtendUtils\HeaderTool.cs" />
     <Compile Include="HttpUtils\MethodUtils\ExtendUtils\HeaderTool.cs" />
     <Compile Include="HttpUtils\MethodUtils\GetUtils\GetToolPlus.cs" />
     <Compile Include="HttpUtils\MethodUtils\GetUtils\GetToolPlus.cs" />

+ 24 - 0
Azylee.Utils/Azylee.YeahWeb/ExtWebAPI/IPAddressAPI/PublicIPAddressModel.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.YeahWeb.ExtWebAPI.IPAddressAPI
+{
+    public class PublicIPAddressModel
+    {
+        public string IP { get; set; }
+        public string ID { get; set; }
+        public string Name { get; set; }
+        public PublicIPAddressModel()
+        {
+
+        }
+        public PublicIPAddressModel(string ip, string id, string name)
+        {
+            this.IP = ip;
+            this.ID = id;
+            this.Name = name;
+        }
+    }
+}

+ 46 - 0
Azylee.Utils/Azylee.YeahWeb/ExtWebAPI/IPAddressAPI/PublicIPAddressTool.cs

@@ -0,0 +1,46 @@
+using Azylee.Core.DataUtils.StringUtils;
+using Azylee.Jsons;
+using Azylee.YeahWeb.HttpUtils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.YeahWeb.ExtWebAPI.IPAddressAPI
+{
+    /// <summary>
+    /// 公网IP地址API
+    /// </summary>
+    public class PublicIPAddressTool
+    {
+        const string URL = "http://pv.sohu.com/cityjson?ie=utf-8";
+
+        /// <summary>
+        /// 获取公网IP地址API
+        /// </summary>
+        /// <returns></returns>
+        public static PublicIPAddressModel GetPublicIP()
+        {
+            string rs = HttpTool.Get(URL);
+            if (Str.Ok(rs))
+            {
+                int flagbeg = rs.IndexOf("{");
+                int flagend = rs.LastIndexOf("}");
+                if (flagbeg < flagend)
+                {
+                    rs = rs.Substring(flagbeg, flagend - flagbeg + 1);
+                    Dictionary<string, string> model = Json.String2Object<Dictionary<string, string>>(rs);
+                    if (model != null)
+                    {
+                        model.TryGetValue("cip", out string cip);
+                        model.TryGetValue("cid", out string cid);
+                        model.TryGetValue("cname", out string cname);
+                        PublicIPAddressModel result = new PublicIPAddressModel(cip, cid, cname);
+                        return result;
+                    }
+                }
+            }
+            return null;
+        }
+    }
+}

+ 49 - 3
Azylee.Utils/Azylee.YeahWeb/SocketUtils/TcpUtils/TcpClientInfo.cs

@@ -11,11 +11,24 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
     /// </summary>
     /// </summary>
     public class TcpClientInfo
     public class TcpClientInfo
     {
     {
+        #region 连接基础信息
         /// <summary>
         /// <summary>
-        /// 唯一编号
+        /// 唯一编号(每次登录都不一样)
         /// </summary>
         /// </summary>
         public int Number { get; set; }
         public int Number { get; set; }
         /// <summary>
         /// <summary>
+        /// 客户端应用程序编码(应用程序区分)
+        /// </summary>
+        public string AppCode { get; set; }
+        /// <summary>
+        /// 连接密钥
+        /// </summary>
+        public string ConnectKey { get; set; }
+        /// <summary>
+        /// 客户端远程终结点IP
+        /// </summary>
+        public string IP { get; set; }
+        /// <summary>
         /// 客户端远程终结点(IP:Port)
         /// 客户端远程终结点(IP:Port)
         /// </summary>
         /// </summary>
         public string Host { get; set; }
         public string Host { get; set; }
@@ -27,10 +40,13 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
         /// 是否连接
         /// 是否连接
         /// </summary>
         /// </summary>
         public bool IsConnect { get; set; }
         public bool IsConnect { get; set; }
+        #endregion
+
+        #region 用户信息及认证
         /// <summary>
         /// <summary>
-        /// 连接密钥
+        /// 权限编码(可扩展权限管理功能)
         /// </summary>
         /// </summary>
-        public string ConnectKey { get; set; }
+        public string AccessCode { get; set; }
         /// <summary>
         /// <summary>
         /// 用户邮箱
         /// 用户邮箱
         /// </summary>
         /// </summary>
@@ -40,6 +56,28 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
         /// </summary>
         /// </summary>
         public string UserName { get; set; }
         public string UserName { get; set; }
         /// <summary>
         /// <summary>
+        /// 主机ID
+        /// </summary>
+        public string MachineID { get; set; }
+        /// <summary>
+        /// 主机名称
+        /// </summary>
+        public string MachineName { get; set; }
+        #endregion
+
+        #region 扩展信息
+        /// <summary>
+        /// 公网IP地址
+        /// </summary>
+        //public string  PublicIP { get; set; }
+        /// <summary>
+        /// 扩展数据
+        /// </summary>
+        //public Dictionary<string, string> ExtData { get; set; }
+        #endregion
+
+        #region 流量管理
+        /// <summary>
         /// 上行流量总计
         /// 上行流量总计
         /// </summary>
         /// </summary>
         public long UploadFlowCount { get; set; }
         public long UploadFlowCount { get; set; }
@@ -56,8 +94,16 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
         /// </summary>
         /// </summary>
         public DateTime LastDownloadTime { get; set; }
         public DateTime LastDownloadTime { get; set; }
         /// <summary>
         /// <summary>
+        /// 心跳通信时间
+        /// </summary>
+        public DateTime HeartbeatTime { get; set; }
+        #endregion
+
+        #region 连接对象
+        /// <summary>
         /// 客户端对象
         /// 客户端对象
         /// </summary>
         /// </summary>
         public TcpClient Client { get; set; }
         public TcpClient Client { get; set; }
+        #endregion
     }
     }
 }
 }

+ 139 - 0
Azylee.Utils/Azylee.YeahWeb/SocketUtils/TcpUtils/TcpClientManager.cs

@@ -101,9 +101,14 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
                 var item = TcpClientList.FirstOrDefault(x => x.Host == host);
                 var item = TcpClientList.FirstOrDefault(x => x.Host == host);
                 if (item == null)
                 if (item == null)
                 {
                 {
+                    string ip = "";
+                    int ipFlagIndex = host.IndexOf(":");
+                    if (ipFlagIndex > 0) ip = host.Substring(0, ipFlagIndex);
+
                     var model = new TcpClientInfo()
                     var model = new TcpClientInfo()
                     {
                     {
                         Number = HostNumber,
                         Number = HostNumber,
+                        IP = ip,
                         Host = host,
                         Host = host,
                         Client = client,
                         Client = client,
                         IsConnect = true,
                         IsConnect = true,
@@ -123,6 +128,12 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
         #endregion
         #endregion
 
 
         #region 更新项
         #region 更新项
+        /// <summary>
+        /// 更新 ConnectKey 连接秘钥
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="s"></param>
+        /// <returns></returns>
         public bool UpdateConnectKey(string host, string s)
         public bool UpdateConnectKey(string host, string s)
         {
         {
             if (IsExistByHost(host))
             if (IsExistByHost(host))
@@ -138,6 +149,12 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
             }
             }
             return false;
             return false;
         }
         }
+        /// <summary>
+        /// 更新 UserEmail 用户邮箱
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="s"></param>
+        /// <returns></returns>
         public bool UpdateUserEmail(string host, string s)
         public bool UpdateUserEmail(string host, string s)
         {
         {
             if (IsExistByHost(host))
             if (IsExistByHost(host))
@@ -153,6 +170,75 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
             }
             }
             return false;
             return false;
         }
         }
+        /// <summary>
+        /// 更新 AccessCode 权限编码
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="s"></param>
+        /// <returns></returns>
+        public bool UpdateAccessCode(string host, string s)
+        {
+            if (IsExistByHost(host))
+            {
+                for (var i = 0; i < TcpClientList.Count; i++)
+                {
+                    if (TcpClientList[i].Host == host)
+                    {
+                        TcpClientList[i].AccessCode = s;
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+        /// <summary>
+        /// 更新 MachineID 主机ID
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="s"></param>
+        /// <returns></returns>
+        public bool UpdateMachineID(string host, string s)
+        {
+            if (IsExistByHost(host))
+            {
+                for (var i = 0; i < TcpClientList.Count; i++)
+                {
+                    if (TcpClientList[i].Host == host)
+                    {
+                        TcpClientList[i].MachineID = s;
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+        /// <summary>
+        /// 更新 MachineName 主机名称
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="s"></param>
+        /// <returns></returns>
+        public bool UpdateMachineName(string host, string s)
+        {
+            if (IsExistByHost(host))
+            {
+                for (var i = 0; i < TcpClientList.Count; i++)
+                {
+                    if (TcpClientList[i].Host == host)
+                    {
+                        TcpClientList[i].MachineName = s;
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+        /// <summary>
+        /// 更新 UserName 用户名
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="s"></param>
+        /// <returns></returns>
         public bool UpdateUserName(string host, string s)
         public bool UpdateUserName(string host, string s)
         {
         {
             if (IsExistByHost(host))
             if (IsExistByHost(host))
@@ -168,6 +254,33 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
             }
             }
             return false;
             return false;
         }
         }
+        /// <summary>
+        /// 更新 AppCode 应用程序编码
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="s"></param>
+        /// <returns></returns>
+        public bool UpdateAppCode(string host, string s)
+        {
+            if (IsExistByHost(host))
+            {
+                for (var i = 0; i < TcpClientList.Count; i++)
+                {
+                    if (TcpClientList[i].Host == host)
+                    {
+                        TcpClientList[i].AppCode = s;
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+        /// <summary>
+        /// 更新上行流量
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="flow"></param>
+        /// <returns></returns>
         public bool UpdateUploadFlowCount(string host, long flow)
         public bool UpdateUploadFlowCount(string host, long flow)
         {
         {
             if (IsExistByHost(host))
             if (IsExistByHost(host))
@@ -184,6 +297,12 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
             }
             }
             return false;
             return false;
         }
         }
+        /// <summary>
+        /// 更新下行流量
+        /// </summary>
+        /// <param name="host"></param>
+        /// <param name="flow"></param>
+        /// <returns></returns>
         public bool UpdateDownloadFlowCount(string host, long flow)
         public bool UpdateDownloadFlowCount(string host, long flow)
         {
         {
             if (IsExistByHost(host))
             if (IsExistByHost(host))
@@ -200,6 +319,26 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
             }
             }
             return false;
             return false;
         }
         }
+        /// <summary>
+        /// 更新心跳时间
+        /// </summary>
+        /// <param name="host"></param>
+        /// <returns></returns>
+        public bool UpdateHeartbeatTime(string host)
+        {
+            if (IsExistByHost(host))
+            {
+                for (var i = 0; i < TcpClientList.Count; i++)
+                {
+                    if (TcpClientList[i].Host == host)
+                    {
+                        TcpClientList[i].HeartbeatTime = DateTime.Now;
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
         #endregion
         #endregion
 
 
         #region 删除项
         #region 删除项

+ 34 - 3
Azylee.Utils/Azylee.YeahWeb/SocketUtils/TcpUtils/TcpDataModel.cs

@@ -22,6 +22,39 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
         /// </summary>
         /// </summary>
         public byte[] Data { get; set; }
         public byte[] Data { get; set; }
         /// <summary>
         /// <summary>
+        /// 默认构造函数
+        /// </summary>
+        public TcpDataModel() { }
+        /// <summary>
+        /// 构造函数(仅指令)
+        /// </summary>
+        /// <param name="type"></param>
+        public TcpDataModel(int type)
+        {
+            this.Type = type;
+        }
+        /// <summary>
+        /// 构造函数(默认)
+        /// </summary>
+        /// <param name="type"></param>
+        /// <param name="data"></param>
+        public TcpDataModel(int type, byte[] data)
+        {
+            this.Type = type;
+            this.Data = data;
+        }
+        /// <summary>
+        /// 构造函数(自动转换)
+        /// </summary>
+        /// <param name="type"></param>
+        /// <param name="data"></param>
+        public TcpDataModel(int type, object data)
+        {
+            this.Type = type;
+            this.Data = Json.Object2Byte(data);
+        }
+
+        /// <summary>
         /// 将当前模型转换为 byte 数组
         /// 将当前模型转换为 byte 数组
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
@@ -56,9 +89,7 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
 
 
                 byte[] data_byte = bytes.Skip(8).Take(length).ToArray();
                 byte[] data_byte = bytes.Skip(8).Take(length).ToArray();
 
 
-                model = new TcpDataModel();
-                model.Type = type;
-                model.Data = data_byte;
+                model = new TcpDataModel(type, data_byte);
             }
             }
             catch { }
             catch { }
             return model;
             return model;

+ 33 - 24
Azylee.Utils/Azylee.YeahWeb/SocketUtils/TcpUtils/TcppClient.cs

@@ -1,7 +1,9 @@
-using Azylee.Core.ThreadUtils.SleepUtils;
+using Azylee.Core.DataUtils.CollectionUtils;
+using Azylee.Core.ThreadUtils.SleepUtils;
 using Azylee.Core.WindowsUtils.ConsoleUtils;
 using Azylee.Core.WindowsUtils.ConsoleUtils;
 using Azylee.Jsons;
 using Azylee.Jsons;
 using System;
 using System;
+using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Net.Sockets;
 using System.Net.Sockets;
@@ -21,6 +23,7 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
         Action OnConnectAction = null;
         Action OnConnectAction = null;
         Action OnDisconnectAction = null;
         Action OnDisconnectAction = null;
         Action<TcpDataModel> OnReceiveAction = null;
         Action<TcpDataModel> OnReceiveAction = null;
+        ConcurrentQueue<Tuple<int, Action<TcpDataModel>>> SyncFunction = new ConcurrentQueue<Tuple<int, Action<TcpDataModel>>>();
 
 
         /// <summary>
         /// <summary>
         /// 构造函数
         /// 构造函数
@@ -72,37 +75,29 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
 
 
         #region 连接后的读写操作
         #region 连接后的读写操作
         /// <summary>
         /// <summary>
-        /// 发送数据
+        /// 发送数据(action禁止使用阻塞操作,必须新建task线程操作)
         /// </summary>
         /// </summary>
         /// <param name="model">数据模型</param>
         /// <param name="model">数据模型</param>
-        public bool Write(TcpDataModel model)
+        /// <param name="actionType">事件驱动处理类型</param>
+        /// <param name="action">事件驱动处理方法</param>
+        public bool Write(TcpDataModel model, int? actionType = 0, Action<TcpDataModel> action = null)
         {
         {
             bool flag = false;
             bool flag = false;
-            if (this.Client != null && this.Client.Connected)
+            if (Client != null && Client.Connected)
             {
             {
                 flag = TcpStreamHelper.Write(Client, model);
                 flag = TcpStreamHelper.Write(Client, model);
             }
             }
+            if (flag)
+            {
+                if (actionType != null && action != null)
+                {
+                    int type = actionType.GetValueOrDefault();
+                    SyncFunction.Enqueue(new Tuple<int, Action<TcpDataModel>>(type, action));
+                }
+            }
             return flag;
             return flag;
         }
         }
         /// <summary>
         /// <summary>
-        /// 发送数据
-        /// </summary>
-        /// <param name="type">类型</param>
-        /// <param name="data">数据</param>
-        public bool Write(int type, byte[] data)
-        {
-            return Write(new TcpDataModel() { Type = type, Data = data });
-        }
-        /// <summary>
-        /// 发送数据
-        /// </summary>
-        /// <param name="type">类型</param>
-        /// <param name="s">字符串</param>
-        public bool Write(int type, string s)
-        {
-            return Write(new TcpDataModel() { Type = type, Data = Json.Object2Byte(s) });
-        }
-        /// <summary>
         /// 接受数据
         /// 接受数据
         /// </summary>
         /// </summary>
         private void acceptCallback(IAsyncResult state)
         private void acceptCallback(IAsyncResult state)
@@ -134,11 +129,25 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
                             if (model.Type == int.MaxValue)
                             if (model.Type == int.MaxValue)
                             {
                             {
                                 //返回心跳
                                 //返回心跳
-                                Write(new TcpDataModel() { Type = int.MaxValue });
+                                Write(new TcpDataModel(int.MaxValue));
                             }
                             }
                             else
                             else
                             {
                             {
-                                OnReceiveAction?.Invoke(model);//委托:接收消息
+                                //优先调用默认接收消息方法Action
+                                OnReceiveAction?.Invoke(model);
+
+                                //调用同步处理委托方法
+                                if (Ls.Ok(SyncFunction))
+                                {
+                                    for (var i = 0; i < SyncFunction.Count; i++)
+                                    {
+                                        bool flag = SyncFunction.TryDequeue(out Tuple<int, Action<TcpDataModel>> fun);
+                                        if (flag)
+                                        {
+                                            Task.Factory.StartNew(() => { fun.Item2?.Invoke(model); });
+                                        }
+                                    }
+                                }
                             }
                             }
                         }
                         }
                     }
                     }

+ 6 - 25
Azylee.Utils/Azylee.YeahWeb/SocketUtils/TcpUtils/TcppServer.cs

@@ -70,7 +70,7 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
         /// </summary>
         /// </summary>
         /// <param name="host">主机地址</param>
         /// <param name="host">主机地址</param>
         /// <param name="model">数据模型</param>
         /// <param name="model">数据模型</param>
-        public void Write(string host, TcpDataModel model)
+        public bool Write(string host, TcpDataModel model)
         {
         {
             var dictionary = TcpClientManager.GetInfoByHost(host);
             var dictionary = TcpClientManager.GetInfoByHost(host);
             if (dictionary != null && dictionary.Client != null)
             if (dictionary != null && dictionary.Client != null)
@@ -79,28 +79,10 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
                 {
                 {
                     TcpClientManager.UpdateUploadFlowCount(host, model.Data.Length);
                     TcpClientManager.UpdateUploadFlowCount(host, model.Data.Length);
                     bool flag = TcpStreamHelper.Write(dictionary.Client, model);
                     bool flag = TcpStreamHelper.Write(dictionary.Client, model);
+                    return flag;
                 }
                 }
             }
             }
-        }
-        /// <summary>
-        /// 发送数据
-        /// </summary>
-        /// <param name="host">主机地址</param>
-        /// <param name="type">类型</param>
-        /// <param name="data">数据</param>
-        public void Write(string host, int type, byte[] data)
-        {
-            Write(host, new TcpDataModel() { Type = type, Data = data });
-        }
-        /// <summary>
-        /// 发送数据
-        /// </summary>
-        /// <param name="host">主机地址</param>
-        /// <param name="type">类型</param>
-        /// <param name="s">字符串</param>
-        public void Write(string host, int type, string s)
-        {
-            Write(host, new TcpDataModel() { Type = type, Data = Json.Object2Byte(s) });
+            return false;
         }
         }
 
 
         private void acceptCallback(IAsyncResult state)
         private void acceptCallback(IAsyncResult state)
@@ -121,14 +103,13 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
         private void ConnectTask(string host, TcpClient client)
         private void ConnectTask(string host, TcpClient client)
         {
         {
             TcpClientInfo clientInfo = TcpClientManager.GetInfoByHost(host);
             TcpClientInfo clientInfo = TcpClientManager.GetInfoByHost(host);
-            DateTime HeartbeatTime = DateTime.Now;
 
 
             //发送心跳
             //发送心跳
             Task.Factory.StartNew(() =>
             Task.Factory.StartNew(() =>
             {
             {
                 while (client.Connected)
                 while (client.Connected)
                 {
                 {
-                    TcpDataModel model = new TcpDataModel() { Type = int.MaxValue };
+                    TcpDataModel model = new TcpDataModel(int.MaxValue);
                     TcpStreamHelper.Write(client, model);
                     TcpStreamHelper.Write(client, model);
 
 
                     Sleep.S(5);
                     Sleep.S(5);
@@ -150,8 +131,8 @@ namespace Azylee.YeahWeb.SocketUtils.TcpUtils
                         {
                         {
                             if (model.Type == int.MaxValue)
                             if (model.Type == int.MaxValue)
                             {
                             {
-                                //过滤心跳
-                                HeartbeatTime = DateTime.Now;
+                                //过滤心跳,并记录心跳时间
+                                TcpClientManager.UpdateHeartbeatTime(host);
                             }
                             }
                             else
                             else
                             {
                             {

+ 1 - 1
Azylee.Utils/Tests/Test.Toast/App.config

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
 <configuration>
     <startup> 
     <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
     </startup>
     </startup>
 </configuration>
 </configuration>

+ 1 - 1
Azylee.Utils/Tests/Test.Toast/Properties/Settings.Designer.cs

@@ -12,7 +12,7 @@ namespace Test.Toast.Properties {
     
     
     
     
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
         
         
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

+ 1 - 1
Azylee.Utils/Tests/Test.Toast/Test.Toast.csproj

@@ -8,7 +8,7 @@
     <OutputType>WinExe</OutputType>
     <OutputType>WinExe</OutputType>
     <RootNamespace>Test.Toast</RootNamespace>
     <RootNamespace>Test.Toast</RootNamespace>
     <AssemblyName>Test.Toast</AssemblyName>
     <AssemblyName>Test.Toast</AssemblyName>
-    <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <FileAlignment>512</FileAlignment>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <TargetFrameworkProfile />
     <TargetFrameworkProfile />