HDL Home App 第二版本 旧平台金堂用 正在使用
xm
2020-05-07 c1de48884fa145a16a0f8bcee93274dcfaa0ff82
ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
old mode 100755 new mode 100644
@@ -101,7 +101,7 @@
            }
        }
        #region variable
        #region variable
        /// <summary>
        /// 远程连接成功时的时间
        /// </summary>
@@ -2857,8 +2857,8 @@
        /// <summary>
        /// 远程MqttClient
        /// </summary>
        public static IMqttClient RemoteMqttClient= new MqttFactory().CreateMqttClient();
        static bool remoteIsConnected;
        public static IMqttClient RemoteMqttClient = new MqttFactory().CreateMqttClient();
        static bool remoteIsConnected;
        private int IsLogin = 0;
        [Newtonsoft.Json.JsonIgnore]
        static Action actionTemp;
@@ -3051,8 +3051,8 @@
           .WithTcpServer(domain, int.Parse(port))
           .WithCredentials(connEmqUserName, connEmqPwd)
           .WithKeepAlivePeriod(TimeSpan.FromSeconds(20))
           .WithCleanSession()
           //.WithCommunicationTimeout(TimeSpan.FromSeconds(10))
           .WithCleanSession()
           //.WithCommunicationTimeout(TimeSpan.FromSeconds(10))
           .Build();
                                await DisConnectRemoteMqttClient("StartRemoteMqtt");
                                await RemoteMqttClient.ConnectAsync(options, CancellationToken.None);
@@ -3087,7 +3087,7 @@
                    localIsConnected = false;
                    DebugPrintLog($"Local主动断开_{s}");
                    //await localMqttClient.DisconnectAsync(new MQTTnet.Client.Disconnecting.MqttClientDisconnectOptions {  }, CancellationToken.None);
                    await localMqttClient.DisconnectAsync();
                    await localMqttClient.DisconnectAsync();
                }
            }
            catch (Exception ex)
@@ -3099,7 +3099,7 @@
        /// <summary>
        /// 断开远程Mqtt的链接
        /// </summary>
        public static async System.Threading.Tasks.Task DisConnectRemoteMqttClient(string s="")
        public static async System.Threading.Tasks.Task DisConnectRemoteMqttClient(string s = "")
        {
            try
            {
@@ -3111,7 +3111,8 @@
                    await RemoteMqttClient.DisconnectAsync();
                }
            }
            catch(Exception e) {
            catch (Exception e)
            {
                DebugPrintLog($"Remote断开通讯连接出异常:{e.Message}");
            }
        }
@@ -3217,7 +3218,7 @@
                        {
                            await localMqttClient.PublishAsync(new MqttApplicationMessage { Topic = topic, Payload = message, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce, Retain = retain });
                        }
                        catch(Exception e)
                        catch (Exception e)
                        {
                            DebugPrintLog($"Local主动断开_{e.Message}");
                            await DisConnectLocalMqttClient(e.Message);
@@ -3336,7 +3337,8 @@
                {
                    return;
                }
                if (topics[2]== "NotifyGateWayInfoChange") {
                if (topics[2] == "NotifyGateWayInfoChange")
                {
                    initGateWayBaseInfomation();
                    return;
                }
@@ -3422,7 +3424,7 @@
        /// <param name="topic">Topic.</param>
        /// <param name="message">Message.</param>
        /// <param name="e">E.</param>
        static void ReceiveMessage(string topic, string message, byte []payload)
        static void ReceiveMessage(string topic, string message, byte[] payload)
        {
            try
            {