From d07d62be7111d78b2aaa44c9cdee23a7d22b4dda Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期二, 22 十二月 2020 10:38:15 +0800
Subject: [PATCH] 20201222-1
---
HDL_ON/DAL/Mqtt/MqttClient.cs | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs
index 7a0d4ff..9246240 100644
--- a/HDL_ON/DAL/Mqtt/MqttClient.cs
+++ b/HDL_ON/DAL/Mqtt/MqttClient.cs
@@ -119,7 +119,7 @@
/// <summary>
/// 澶栫綉鐨凪QTT鏄惁姝e湪杩炴帴
/// </summary>
- public static bool remoteMqttIsConnecting;
+ public static bool RemoteMqttIsConnecting;
static bool remoteIsConnected;
static MqttClient()
@@ -138,6 +138,8 @@
{
System.Threading.Thread.Sleep(500);
if (!Control.Ins.IsRemote) continue;
+ //杩涘叆鍚庡彴涓嶅鐞�
+ if (MainPage.IsEnterBackground) continue;
await StartCloudMqtt();
await SubscribeTopics();
@@ -221,7 +223,7 @@
}
//杩藉姞锛氭病鏈夎繙绋嬭繛鎺ョ殑鏉冮檺
- if (remoteMqttIsConnecting || remoteIsConnected)
+ if (RemoteMqttIsConnecting || remoteIsConnected)
{
return;
}
@@ -232,7 +234,7 @@
try
{
#region 鍒濆鍖栬繙绋婱qtt
- remoteMqttIsConnecting = true;
+ RemoteMqttIsConnecting = true;
RemoteMqttClient = new MqttFactory().CreateMqttClient();
@@ -267,6 +269,7 @@
}
else
{
+ MainPage.Log($"mqtt data");
SetGatewayOnlineResetCheck();
var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, DB_ResidenceData.Instance.HomeGateway.aesKey);
@@ -310,9 +313,23 @@
if (RemoteMqttClient.ConnectedHandler == null)
{
RemoteMqttClient.UseConnectedHandler(async (e) => {
- if (DB_ResidenceData.Instance.HomeGateway.GatewayOnline)
+ if (DB_ResidenceData.Instance.HomeGateway.gatewayStatus)
{
Control.Ins.GatewayOnline = true;
+ }
+ else
+ {
+ //new System.Threading.Thread(() => {
+ // while(true)
+ // {
+ // System.Threading.Thread.Sleep(1000);
+ // if (DB_ResidenceData.Instance.HomeGateway.GatewayOnline)
+ // {
+ // Control.Ins.GatewayOnline = true;
+ // break;
+ // }
+ // }
+ //}) { IsBackground = true }.Start();
}
IfNeedReadAllDeviceStatus = true;
Utlis.WriteLine($"============>Mqtt杩滅▼杩炴帴鎴愬姛");
@@ -343,7 +360,7 @@
finally
{
//鏈�缁堣閲婃斁杩炴帴鐘舵��
- remoteMqttIsConnecting = false;
+ RemoteMqttIsConnecting = false;
Utlis.WriteLine($"StartCloudMqtt: 缁撴潫");
}
--
Gitblit v1.8.0