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);