From c1863db0158fb6c2a1cd96686d514c98c1073937 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 17 一月 2020 11:58:18 +0800 Subject: [PATCH] 2020-01-17 --- Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs | 29 ++++++++++++----------------- 1 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs index 2536317..c01deed 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs @@ -46,6 +46,10 @@ InitMqtt (); } + /// <summary> + /// 淇濇椿閲嶈繛鍜岄噸璁㈤槄 绾跨▼ + /// </summary> + /// <returns></returns> public static async System.Threading.Tasks.Task InitMqtt () { new System.Threading.Thread (async () => { @@ -92,8 +96,6 @@ Topic = $"/BusGateWayToClient/{mMqttInfo.connEmqClientId}/Push/NotifySqueeze", QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce }; - - var topicFilters = new TopicFilter [] { topicFilterCommon, topicFilterGateWayInfoChange, topicFilterNotifySqueeze }; var result = await RemoteMqttClient.SubscribeAsync (topicFilters); @@ -146,21 +148,11 @@ public static async System.Threading.Tasks.Task StartCloudMqtt () { - //Application.RunOnMainThread (() => { - // if (5 < (DateTime.Now - dateTime).TotalSeconds) { - // return; - // } - // //MainPage.Loading.Start (Language.StringByID (Shared.SimpleControl.R.MyInternationalizationString.Connecting)); - // dateTime = DateTime.Now; - //}); if (!MainPage.LoginUser.IsLogin) { return; } //杩藉姞锛氭病鏈夎繙绋嬭繛鎺ョ殑鏉冮檺 - if (remoteMqttIsConnecting - || remoteIsConnected) { - //System.Console.WriteLine ($"============>MqttremoteMqttIsConnecting:{remoteMqttIsConnecting} remoteIsConnected:{remoteIsConnected} "); - + if (remoteMqttIsConnecting || remoteIsConnected) { return; } @@ -268,9 +260,6 @@ if (CurRemoteMACInfo != null) { if (CurRemoteMACInfo.isValid == "InValid") { MainPage.AddTip ("Remote failed,gateway offline"); - //Application.RunOnMainThread (() => { - // MainPage.Loading.Hide (); - //}); } else { MqttRemoteSend (new byte [] { 0 }, 3); } @@ -389,6 +378,11 @@ public static async Task MqttRemoteSend (byte [] message, int optionType = 0) { try { + if (!remoteIsConnected) { + System.Console.WriteLine ($"============>Mqtt 鏈繛鎺� 鍙栨秷鍙戦��"); + return; + } + var topicName = @"/" + MainPage.LoginUser.AccountString.ToLower () + @"/" + UserConfig.Instance.GatewayMAC.Replace (".", "") + @"/" + currentGuid; switch (optionType) { case 0: @@ -541,11 +535,12 @@ MainPage.LoginUser.LastTime = DateTime.Now.AddDays (-30); MainPage.LoginUser.SaveUserInfo (); - DisConnectRemoteMqttClient ("LoginOut"); + DisConnectRemoteMqttClient ("鎸や笅绾�"); MainPage.ShowAlertOnMainThread (ErrorCode.LoginInAnotherDevice); Application.RunOnMainThread (() => { + MainPage.WiFiStatus = "CrabtreeAdd/WiFi.png"; UserMiddle.btnLinkStatus.UnSelectedImagePath = MainPage.WiFiStatus; new AccountLogin ().Show (); -- Gitblit v1.8.0