From 8edf8fd9f5f7c29cc6302a8d46de06d391ed3657 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 16 一月 2020 13:03:57 +0800 Subject: [PATCH] 2020-01-16 Version 2.50115-B3 1.优化MQTT连接。 2.增加本地通信加密。 3.增加配置网关提示语。 4.编辑定时器增加重复名字提示 5.更新规范翻译。 --- Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs | 28 +++++++++++----------------- 1 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs index 2536317..997458f 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,7 +535,7 @@ MainPage.LoginUser.LastTime = DateTime.Now.AddDays (-30); MainPage.LoginUser.SaveUserInfo (); - DisConnectRemoteMqttClient ("LoginOut"); + DisConnectRemoteMqttClient ("鎸や笅绾�"); MainPage.ShowAlertOnMainThread (ErrorCode.LoginInAnotherDevice); -- Gitblit v1.8.0