From be95e839f40eb3ddf64706b60cba6dfcf4fad5e5 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 03 四月 2020 14:31:44 +0800 Subject: [PATCH] 2020-04-03 1.去掉登录前ping百度域名的网络监测。 --- Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs | 56 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs index 8650a0b..0d6fb64 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs @@ -130,17 +130,17 @@ try { if (remoteIsConnected) { remoteIsConnected = false; - System.Console.WriteLine ($"============>MqttRemote涓诲姩鏂紑_{s}"); + Utlis.WriteLine ($"============>MqttRemote涓诲姩鏂紑_{s}"); //await RemoteMqttClient.DisconnectAsync(new MQTTnet.Client.Disconnecting.MqttClientDisconnectOptions { }, CancellationToken.None); await RemoteMqttClient.DisconnectAsync (); if (CommonPage.IsRemote) { Utlis.ShowAppLinkStatus (AppLinkStatus.CloudUnlink); } - System.Console.WriteLine ($"============>MqttRemoteDisConnectRemoteMqttClient"); + Utlis.WriteLine ($"============>MqttRemoteDisConnectRemoteMqttClient"); } } catch (Exception e) { - System.Console.WriteLine ($"============>MqttRemote鏂紑閫氳杩炴帴鍑哄紓甯�:{e.Message}"); + Utlis.WriteLine ($"============>MqttRemote鏂紑閫氳杩炴帴鍑哄紓甯�:{e.Message}"); } } static DateTime dateTime = DateTime.MinValue; @@ -189,7 +189,7 @@ } var aesDecryptTopic = e.ApplicationMessage.Topic; var aesDecryptPayload = e.ApplicationMessage.Payload; - //Console.WriteLine ("Topic={0}", aesDecryptTopic); + //Utlis.WriteLine ("Topic={0}", aesDecryptTopic); //if (aesDecryptTopic == $"NotifyBusGateWayInfoChagne/{CurRemoteMACInfo.md5_mac_string}") {//缃戝叧涓婄嚎锛岄渶瑕佹洿鏂癮eskey //2020-01-11 淇敼璁㈤槄涓婚鍦板潃 @@ -221,7 +221,7 @@ if (RemoteMqttClient.DisconnectedHandler == null) { RemoteMqttClient.UseDisconnectedHandler (async (e) => { - System.Console.WriteLine ($"============>Mqtt杩滅▼杩炴帴鏂紑"); + Utlis.WriteLine ($"============>Mqtt杩滅▼杩炴帴鏂紑"); isSubscribeTopicSuccess = false; await DisConnectRemoteMqttClient ("StartRemoteMqtt.DisconnectedHandler"); //await StartRemoteMqtt(); @@ -240,7 +240,7 @@ RemoteMqttClient.UseConnectedHandler (async (e) => { IfNeedReadAllDeviceStatus = true; - System.Console.WriteLine ($"============>Mqtt杩滅▼杩炴帴鎴愬姛"); + Utlis.WriteLine ($"============>Mqtt杩滅▼杩炴帴鎴愬姛"); if (CommonPage.IsRemote) { Utlis.ShowAppLinkStatus (AppLinkStatus.CloudLink); } @@ -304,7 +304,7 @@ await MQTTConnectAsync (); } else { - System.Console.WriteLine ("============>Mqtt 鍙栨秷杩炴帴锛屽綋鍓嶄綇瀹呮病缁戝畾缃戝叧"); + Utlis.WriteLine ("============>Mqtt 鍙栨秷杩炴帴锛屽綋鍓嶄綇瀹呮病缁戝畾缃戝叧"); } } @@ -334,7 +334,7 @@ } } catch (Exception ex) { - System.Console.WriteLine ($"============>Mqtt 杩滅▼杩炴帴閫氳杩炴帴鍑哄紓甯�:{ex.Message}"); + Utlis.WriteLine ($"============>Mqtt 杩滅▼杩炴帴閫氳杩炴帴鍑哄紓甯�:{ex.Message}"); } finally { //鏈�缁堣閲婃斁杩炴帴鐘舵�� remoteMqttIsConnecting = false; @@ -386,7 +386,7 @@ //{ // try { // if (!remoteIsConnected) { - // System.Console.WriteLine ($"============>Mqtt 鏈繛鎺� 鍙栨秷鍙戦��"); + // Utlis.WriteLine ($"============>Mqtt 鏈繛鎺� 鍙栨秷鍙戦��"); // return; // } @@ -420,10 +420,10 @@ // var m1 = new MqttApplicationMessage { Topic = topicName, Retain = false, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce }; // try { - // Console.WriteLine ("CheckGateway"); + // Utlis.WriteLine ("CheckGateway"); // RemoteMqttClient.PublishAsync (m1); // } catch (Exception e) { - // Console.WriteLine ($"CheckGateway Fail:{e.Message}"); + // Utlis.WriteLine ($"CheckGateway Fail:{e.Message}"); // //await DisConnectRemoteMqttClient (e.Message); // //await StartCloudMqtt (); // } @@ -446,7 +446,7 @@ { try { //if (!remoteIsConnected) { - // System.Console.WriteLine ($"============>Mqtt 鏈繛鎺� 鍙栨秷鍙戦��"); + // Utlis.WriteLine ($"============>Mqtt 鏈繛鎺� 鍙栨秷鍙戦��"); // return; //} @@ -461,12 +461,12 @@ break; case 3: topicName = $"/ClientToBusGateWay/{CurRemoteMACInfo.macMark}/Common/CheckGateway"; - //Console.WriteLine ("CheckGateway"); + //Utlis.WriteLine ("CheckGateway"); await RemoteMqttClient.PublishAsync (new MqttApplicationMessage { Topic = topicName, Retain = false, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }); break; } } catch (Exception e) { - // System.Console.WriteLine ($"============>Mqtt MqttRemoteSend catch"); + // Utlis.WriteLine ($"============>Mqtt MqttRemoteSend catch"); if (!IsDisConnectingWithSendCatch) { IsDisConnectingWithSendCatch = true; await DisConnectRemoteMqttClient ("MqttRemoteSendCatch"); @@ -524,7 +524,7 @@ } else { - System.Console.WriteLine ("============>Mqtt 鍙栨秷杩炴帴锛屽綋鍓嶄綇瀹呮病缁戝畾缃戝叧"); + Utlis.WriteLine ("============>Mqtt 鍙栨秷杩炴帴锛屽綋鍓嶄綇瀹呮病缁戝畾缃戝叧"); } } else { var mGatewayRes = infoResult.PageData.Find ((obj) => obj.GatewayUniqueId == UserConfig.Instance.CurrentRegion.HomeGateways [0].GatewayUniqueId); @@ -549,7 +549,7 @@ /// </summary> static async Task ReceiveNotifyBusGateWayInfoChange () { - System.Console.WriteLine ("============>Mqtt 缃戝叧涓婄嚎"); + Utlis.WriteLine ("============>Mqtt 缃戝叧涓婄嚎"); SetGatewayOnlineResetCheck (); if (CommonPage.IsRemote) { @@ -586,7 +586,7 @@ /// </summary> static void ReceiveNotifyGateWayOffline () { - System.Console.WriteLine ("============>Mqtt GateWayOffline"); + Utlis.WriteLine ("============>Mqtt GateWayOffline"); IsGatewayOnline = false; if (CommonPage.IsRemote) { Utlis.ShowAppLinkStatus (AppLinkStatus.CloudOffline); @@ -650,7 +650,7 @@ MqttRemoteSend (new byte [] { }, 3); CheckGatewayCount++; #if DEBUG - Console.WriteLine ("CheckGateway"); + Utlis.WriteLine ("CheckGateway"); #endif @@ -669,7 +669,7 @@ /// 鏀跺埌CheckGateway涓婚 /// </summary> static void ReceiveCheckGatewayTopic () { - //System.Console.WriteLine ("============>Mqtt CheckGateway缃戝叧鍥炲"); + //Utlis.WriteLine ("============>Mqtt CheckGateway缃戝叧鍥炲"); SetGatewayOnlineResetCheck (); @@ -720,7 +720,7 @@ /// </summary> static async Task ReceiveNotifySqueezeAsync (byte [] mes) { - Console.WriteLine ($"============>MqttNotifySqueeze: {ErrorCode.LoginInAnotherDevice}"); + Utlis.WriteLine ($"============>MqttNotifySqueeze: {ErrorCode.LoginInAnotherDevice}"); var mMes = CommonPage.MyEncodingUTF8.GetString (mes); if (mMes == PushSignStr) return;//鏄嚜宸辩殑鐧诲綍鎺ㄩ�佷笉澶勭悊 @@ -998,7 +998,7 @@ RemoteMqttClient = null; } CommonPage.IsRemote = false; - Console.WriteLine ("Close Mqtt!!!"); + Utlis.WriteLine ("Close Mqtt!!!"); } catch { } } @@ -1088,7 +1088,7 @@ webPush.DeleteToken_Push (UserConfig.Instance.tokenID); }); } catch (Exception ex) { - Console.WriteLine (ex.Message); + Utlis.WriteLine (ex.Message); } finally { Application.RunOnMainThread (() => { Shared.SimpleControl.Phone.UserMiddle.LinkStatusTip.BackgroundColor = SkinStyle.Current.LinkStatusTipColor; @@ -1154,7 +1154,7 @@ }); RemoteMqttClient.UseDisconnectedHandler (e => { - //Console.WriteLine ("RemoteMqttClient UseDisconnectedHandler"); + //Utlis.WriteLine ("RemoteMqttClient UseDisconnectedHandler"); if (thisShowTip) { if (CommonPage.IsRemote) { //MainPage.AddTip (Language.StringByID (Shared.SimpleControl.R.MyInternationalizationString.RemoteConnectionDisconnected)); @@ -1168,7 +1168,7 @@ } }); RemoteMqttClient.UseConnectedHandler (async e => { - //Console.WriteLine ("RemoteMqttClient IsRemote"); + //Utlis.WriteLine ("RemoteMqttClient IsRemote"); await MqttCheckGateway (); }); } @@ -1181,14 +1181,14 @@ MainPage.Loading.Hide (); Shared.SimpleControl.Phone.UserMiddle.LinkStatusTip.BackgroundColor = SkinStyle.Current.DelColor; }); - System.Console.WriteLine ($"閲嶆柊杩炴帴杩滅▼閫氳澶辫触锛屽洜涓鸿幏鍙栨柊鐨凨EY澶辫触"); + Utlis.WriteLine ($"閲嶆柊杩炴帴杩滅▼閫氳澶辫触锛屽洜涓鸿幏鍙栨柊鐨凨EY澶辫触"); return; } //var messgae = System.Text.Encoding.UTF8.GetString (tempResult); var responsePack = tempResult.ResponseData;// Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>> (messgae); //if (responsePack == null || responsePack ["ResponseData"] == null) { - // Console.WriteLine ("鏂紑鍚庨噸鏂伴摼鎺ラ渶瑕侀噸鏂扮櫥褰曡幏鍙栬繛鎺ョ殑瀵嗙爜澶辫触"); + // Utlis.WriteLine ("鏂紑鍚庨噸鏂伴摼鎺ラ渶瑕侀噸鏂扮櫥褰曡幏鍙栬繛鎺ョ殑瀵嗙爜澶辫触"); // return; //} var dictrionaryResult = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>> (tempResult.ResponseData.ToString ()); @@ -1216,7 +1216,7 @@ await Close (); await RemoteMqttClient.ConnectAsync (options); } catch (Exception ex) { - System.Console.WriteLine ("============>" + ex.Message); + Utlis.WriteLine ("============>" + ex.Message); Application.RunOnMainThread (() => { MainPage.Loading.Hide (); isConnecting = false.ToString (); @@ -1310,7 +1310,7 @@ return; } var topicName = @"/" + MainPage.LoginUser.AccountString.ToLower () + @"/CheckGateway/" + UserConfig.Instance.GatewayMAC.Replace (".", ""); - Console.WriteLine ("MqttCheckGateway : " + topicName); + Utlis.WriteLine ("MqttCheckGateway : " + topicName); //base64鍔犲瘑涓婚 var topicNameBase64 = Shared.Securitys.EncryptionService.AesEncryptTopic (topicName, mqttEncryptKey); -- Gitblit v1.8.0