From f77a3add1e7ab266e473da9128bbe5758ba3a890 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期日, 20 十二月 2020 19:29:03 +0800 Subject: [PATCH] Merge branch 'NewFilePath' into CJL --- HDL_ON/DAL/Mqtt/MqttClient.cs | 64 ++++++++++++++++++++++---------- 1 files changed, 44 insertions(+), 20 deletions(-) diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index 321d8b1..1606485 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -119,7 +119,7 @@ /// <summary> /// 澶栫綉鐨凪QTT鏄惁姝e湪杩炴帴 /// </summary> - public static bool remoteMqttIsConnecting; + public static bool RemoteMqttIsConnecting; static bool remoteIsConnected; static MqttClient() @@ -138,6 +138,8 @@ { System.Threading.Thread.Sleep(500); if (!Control.Ins.IsRemote) continue; + //杩涘叆鍚庡彴涓嶅鐞� + if (MainPage.IsEnterBackground) continue; await StartCloudMqtt(); await SubscribeTopics(); @@ -210,7 +212,7 @@ /// </summary> public static async Task StartCloudMqtt() { - if (OnAppConfig.Instance.internetStatus == 0) + if (MainPage.InternetStatus == 0) { return; } @@ -221,7 +223,7 @@ } //杩藉姞锛氭病鏈夎繙绋嬭繛鎺ョ殑鏉冮檺 - if (remoteMqttIsConnecting || remoteIsConnected) + if (RemoteMqttIsConnecting || remoteIsConnected) { return; } @@ -232,7 +234,7 @@ try { #region 鍒濆鍖栬繙绋婱qtt - remoteMqttIsConnecting = true; + RemoteMqttIsConnecting = true; RemoteMqttClient = new MqttFactory().CreateMqttClient(); @@ -268,9 +270,10 @@ else { SetGatewayOnlineResetCheck(); - Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, DB_ResidenceData.residenceData.HomeGateway.aesKey); + var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, DB_ResidenceData.Instance.HomeGateway.aesKey); + //bus鏁版嵁瑙f瀽 - if (DB_ResidenceData.residenceData.GatewayType == 0) + if (DB_ResidenceData.Instance.GatewayType == 0) { var packet = new Packet(); @@ -287,8 +290,8 @@ else { //A鍗忚鏁版嵁澶勭悊 - var revString = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); - Control.Ins.UpdataFunctionStatus(revString); + var revString = Encoding.UTF8.GetString(bytes); + Control.Ins.UpdataFunctionStatus(revString,null); } } } @@ -309,10 +312,27 @@ if (RemoteMqttClient.ConnectedHandler == null) { RemoteMqttClient.UseConnectedHandler(async (e) => { + if (DB_ResidenceData.Instance.HomeGateway.gatewayStatus) + { + Control.Ins.GatewayOnline = true; + } + else + { + //new System.Threading.Thread(() => { + // while(true) + // { + // System.Threading.Thread.Sleep(1000); + // if (DB_ResidenceData.Instance.HomeGateway.GatewayOnline) + // { + // Control.Ins.GatewayOnline = true; + // break; + // } + // } + //}) { IsBackground = true }.Start(); + } IfNeedReadAllDeviceStatus = true; Utlis.WriteLine($"============>Mqtt杩滅▼杩炴帴鎴愬姛"); SendPushSignOut(); - FunctionList.List.ReadAllFunctionStatus(); }); } #endregion @@ -339,7 +359,7 @@ finally { //鏈�缁堣閲婃斁杩炴帴鐘舵�� - remoteMqttIsConnecting = false; + RemoteMqttIsConnecting = false; Utlis.WriteLine($"StartCloudMqtt: 缁撴潫"); } @@ -369,7 +389,7 @@ { try { - if (MqttInfoConfig.Current.HomeGatewayInfo != null && MqttInfoConfig.Current.HomeGatewayInfo.mac == Entity.DB_ResidenceData.residenceData.residenceGatewayMAC) + if (MqttInfoConfig.Current.HomeGatewayInfo != null && MqttInfoConfig.Current.HomeGatewayInfo.mac == Entity.DB_ResidenceData.Instance.residenceGatewayMAC) { await MQTTConnectAsync(); } @@ -522,7 +542,9 @@ /// </summary> static void ReceiveNotifySqueezeAsync(string mMes) { - +#if DEBUG + return; +#endif if (mMes == PushSignStr) return;//鏄嚜宸辩殑鐧诲綍鎺ㄩ�佷笉澶勭悊 //鏂紑杩滅▼杩炴帴 @@ -534,13 +556,15 @@ DisConnectRemoteMqttClient("鎸や笅绾�"); - UserInfo.Current.LastTime = DateTime.MinValue; - UserInfo.Current.SaveUserInfo(); + HDLCommon.Current.CheckLogout(); - Application.RunOnMainThread(() => { - MainPage.GoLoginPage(UserInfo.Current); - //寮圭獥鎻愮ず琚尋涓嬬嚎 - }); + //UserInfo.Current.LastTime = DateTime.MinValue; + //UserInfo.Current.SaveUserInfo(); + + //Application.RunOnMainThread(() => { + // MainPage.GoLoginPage(UserInfo.Current); + // //寮圭獥鎻愮ず琚尋涓嬬嚎 + //}); //2020-08-11 鍒犻櫎鎺ㄩ�佹暟鎹� //HDLRequest.Current.PushserivceSignOut (); @@ -652,10 +676,10 @@ MqttInfoConfig.Current.mMqttInfo = mqttInfoRequestResult_Obj; await MQTTConnectAsync(); //1.鍒ゆ柇鏄惁缁戝畾浜嗙綉鍏筹紝鑾峰彇缃戝叧杩滅▼杩炴帴鐨勫姞瀵咾EY - if (DB_ResidenceData.residenceData.CheckWhetherGatewayIsBound()) + if (DB_ResidenceData.Instance.CheckWhetherGatewayIsBound()) { //2.鎵惧嚭鏄惁瀛樺湪鍖归厤褰撳墠浣忓畢鐨刴ac锛屽瓨鍦ㄥ啀杩涜杩滅▼銆� - MqttInfoConfig.Current.HomeGatewayInfo = DB_ResidenceData.residenceData.HomeGateway; + MqttInfoConfig.Current.HomeGatewayInfo = DB_ResidenceData.Instance.HomeGateway; //3.寮�濮嬭繛鎺� await MQTTConnectAsync(); } -- Gitblit v1.8.0