From 2bbb1b72dbce5cf9bd4ac4a5b7488e3f18eaf929 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期六, 19 十二月 2020 18:37:38 +0800
Subject: [PATCH] 2020-12-19 1.IOS和Android网络切换,远程和本地控制切换优化。  2.IOS和Android后台回到前台,搜索网关,远程和本地控制切换优化.

---
 HDL-ON_Android/Application.cs |   39 +++++++++++++++++++++++++++++++--------
 1 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/HDL-ON_Android/Application.cs b/HDL-ON_Android/Application.cs
index 3d80e26..44e4c01 100644
--- a/HDL-ON_Android/Application.cs
+++ b/HDL-ON_Android/Application.cs
@@ -86,7 +86,7 @@
                     //}
 
                     //缃戠粶鍙樺寲澶勭悊
-                    HDLCommon.Current.UpdateInternetStatus((int)internetStatus, IsEnterBackground);
+                    HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground);
                 };
                 //寮�鍚畾浣嶆湇鍔�
                 Shared.Application.StartGPSLocationService();
@@ -309,30 +309,53 @@
 
         int mCount;
 
+        ///// <summary>
+        ///// 鏄惁杩涘叆鍚庡彴
+        ///// </summary>
+        //public bool IsEnterBackground = false;
+
         /// <summary>
-        /// 鏄惁杩涘叆鍚庡彴
+        /// 杩涘叆鍚庡彴鐨勬椂闂�
         /// </summary>
-        public bool IsEnterBackground = false;
+        DateTime CloseTime = DateTime.Now;
 
         /// <summary>
         /// BusSocketStop
         /// </summary>
         void BusSocketStop()
         {
-            IsEnterBackground = true;
-            //BusSocket.Stop();
+            //IsEnterBackground = true;
+            CloseTime = DateTime.Now;
+            MainPage.IsEnterBackground = true;
+            //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵��
+            HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false;
+            HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop();
+           
         }
-
 
         /// <summary>
         /// BusSocketStart
         /// </summary>
         void BusSocketStart()
         {
-            IsEnterBackground = false;
+            //IsEnterBackground = false;
 
-            //BusSocket.Start();
+            if (CloseTime.AddSeconds(10) < DateTime.Now)
+            {
+                //鍚庡彴瓒呰繃10s灏辨柇寮�MQTT閲嶈繛
+                if (HDL_ON.DriverLayer.Control.Ins.IsRemote)
+                {
+                    HDL_ON.DAL.Mqtt.MqttClient.DisConnectRemote("closeTime", false);
+                }
+            }
+
+            MainPage.IsEnterBackground = false;
+            HDL_ON.DriverLayer.UdpSocket._BusSocket.Start();
+            HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
         }
+
+      
+
     }
 
 }
\ No newline at end of file

--
Gitblit v1.8.0