From dc9a1b15bb69227e19afc070adf58156a362d2a2 Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期一, 30 九月 2024 17:07:58 +0800
Subject: [PATCH] 安卓可视对讲响铃,
---
HDL_ON/DAL/Mqtt/MqttClient.cs | 112 ++++++++++++++++++++++++++-----------------------------
1 files changed, 53 insertions(+), 59 deletions(-)
diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs
index 9c11563..9593aef 100644
--- a/HDL_ON/DAL/Mqtt/MqttClient.cs
+++ b/HDL_ON/DAL/Mqtt/MqttClient.cs
@@ -13,6 +13,8 @@
using HDL_ON.UI;
using HDL_ON.DAL.Server;
using HDL_ON;
+using Newtonsoft.Json;
+using System.Collections.Generic;
namespace HDL_ON.DAL.Mqtt
{
@@ -57,7 +59,7 @@
/// <summary>
/// 鎺ㄩ�佹爣璇�
/// </summary>
- static string PushSignStr = DateTime.Now.Ticks.ToString();
+ static string PushSignStr = OnAppConfig.Instance.PushSignStr;
/// <summary>
/// 鏂紑杩滅▼Mqtt鐨勯摼鎺�
@@ -111,7 +113,7 @@
{
MqttInfoConfig.Current.IfGetMqttInfoSuccess = false;
}
- Control.Ins.GatewayOnline_Cloud = Control.Ins.GatewayOnline_Local = false;
+ //Control.Ins.GatewayOnline_Cloud = Control.Ins.GatewayOnline_Local = false;
await DisConnectRemoteMqttClient(s);
}
@@ -133,10 +135,6 @@
new System.Threading.Thread(async () => {
while (true)
{
- if (!UserInfo.Current.IsLogin)
- {
- return;
- }
try
{
System.Threading.Thread.Sleep(2000);
@@ -149,6 +147,7 @@
await StartCloudMqtt();
await SubscribeTopics();
+
}
catch { }
}
@@ -162,6 +161,7 @@
public static void InitState()
{
IfNeedReadAllDeviceStatus = true;
+ Common.ApiUtlis.Ins.hadInternet = true;
StartCloudMqtt();
}
@@ -341,17 +341,23 @@
public static async Task StartCloudMqtt()
{
//娌℃湁缃戠粶鐨勭姸鎬佷笅灏濊瘯涓�涓嬭繛鎺qtt 锛屽畨鍗撶殑缃戠粶鐘舵�佸彉鍖栫洃鍚湁寮傚父锛屼慨鏀瑰簳灞傞夯鐑�
- if (MainPage.InternetStatus == 0 && MainPage.LinkHdlMqttCount > 1)
+ if (MainPage.InternetStatus == 0 && MainPage.LinkHdlMqttCount > 1 )
+ {
+ return;
+ }
+
+
+ if (!Common.ApiUtlis.Ins.hadInternet)
{
return;
}
MainPage.LinkHdlMqttCount++;
- if (!UserInfo.Current.IsLogin)
- {
- return;
- }
- if (DB_ResidenceData.Instance.CurrentRegion == null || DB_ResidenceData.Instance.CurrentRegion.id == null)
+ //if (!UserInfo.Current.IsLogin)
+ //{
+ // return;
+ //}
+ if (OnAppConfig.Instance.LastLoginUserId == ""|| DB_ResidenceData.Instance.CurrentRegion == null || DB_ResidenceData.Instance.CurrentRegion.id == null)
{
return;
}
@@ -367,6 +373,26 @@
await Task.Factory.StartNew((Func<Task>)(async () => {
try
{
+ try
+ {
+ //澧炲姞3绉掍簯鏈嶅姟鍣ㄨ繛鎺ユ娴嬶紝杩炰笉涓婃湇鍔″櫒鐨勬椂鍊欎笉鍒锋柊鏁版嵁
+ var dataList = new List<GlobalRegionListRes>();
+ var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark });
+ var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost, "", 3);
+ if (revertObj == null || revertObj.Code != StateCode.SUCCESS)
+ {
+ Common.ApiUtlis.Ins.hadInternet = false;
+ return;
+ }
+ else
+ {
+ Common.ApiUtlis.Ins.hadInternet = true;
+ }
+ }
+ catch
+ {
+ }
+
#region 鍒濆鍖栬繙绋婱qtt
RemoteMqttIsConnecting = true;
RemoteMqttClient = new MqttFactory().CreateMqttClient();
@@ -834,23 +860,8 @@
/// </summary>
static void ReceiveNotifySqueezeAsync(string mMes)
{
-#if DEBUG
- //return;
-#endif
+ MainPage.Log($"鎺ㄩ�佹爣璇嗭細{mMes};鏈湴鏍囪瘑锛歿PushSignStr}");
if (mMes == PushSignStr) return;//鏄嚜宸辩殑鐧诲綍鎺ㄩ�佷笉澶勭悊//鎴栬�呭綋鍓嶄笉鏄繙绋嬮摼鎺ョ姸鎬�
- //娴嬭瘯璐﹀彿锛屼笉鎸や笅绾�
- switch (UserInfo.Current.userMobileInfo)
- {
- case "18316672920":
- case "15626203746":
- case "464027401@qq.com":
- return;
- }
-
- if (!UserInfo.Current.IsLogin)
- {
- return;
- }
DisConnectRemoteMqttClient("鎸や笅绾�");
@@ -859,44 +870,28 @@
//寮圭獥鎻愮ず琚尋涓嬬嚎
HDLCommon.Current.CheckLogout();
});
-
-
- //UserInfo.Current.LastTime = DateTime.MinValue;
- //UserInfo.Current.SaveUserInfo();
-
- //Application.RunOnMainThread(() => {
- // MainPage.GoLoginPage(UserInfo.Current);
- // //寮圭獥鎻愮ず琚尋涓嬬嚎
- //});
-
- //2020-08-11 鍒犻櫎鎺ㄩ�佹暟鎹�
- //HDLRequest.Current.PushserivceSignOut ();
}
-
- ///// <summary>
- ///// 鏀跺埌CheckGateway涓婚
- ///// </summary>
- //static void ReceiveCheckGateway(string mMes)
- //{
- // if (!Control.Ins.IsRemote) return;
-
- // Utlis.WriteLine("ReceiveCheckGateway锛�");
-
- // //CheckIfNeedReadAllDeviceStatus ();
-
- // //var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(mMes);
- // Control.Ins.GatewayOnline = true;
- //}
/// <summary>
/// 鎺ㄩ�佹尋涓嬬嚎涓婚
/// </summary>
static void SendPushSignOut()
{
- byte[] message = Encoding.UTF8.GetBytes(PushSignStr);
#if DEBUG
- MqttRemoteSend(message, 4);
+ MainPage.Log("璋冭瘯妯″紡锛屼笉鍙戝竷鎸や笅绾夸富棰樸��");
+ return;
#endif
+ //娴嬭瘯璐﹀彿锛屼笉鎸や笅绾�
+ switch (UserInfo.Current.AccountString)
+ {
+ case "15626203746":
+ case "13580507523":
+ case "18475593023":
+ return;
+ }
+
+ byte[] message = Encoding.UTF8.GetBytes(PushSignStr);
+ MqttRemoteSend(message, 4);
}
/// <summary>
@@ -922,7 +917,6 @@
break;
case 4://鍙戝竷鏂版柟妗堢殑鎸や笅绾夸富棰�
topicName = $"/BusGateWayToClient/{UserInfo.Current.ID}" + PushNotifySqueeze;
- //message = Encoding.UTF8.GetBytes (PushSignStr);
await RemoteMqttClient.PublishAsync(new MqttApplicationMessage { Topic = topicName, Payload = message, Retain = false, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce });
break;
}
@@ -984,7 +978,7 @@
MqttInfoConfig.Current.mMqttInfo = mqttInfoRequestResult_Obj;
- await MQTTConnectAsync();
+ //await MQTTConnectAsync();
//1.鍒ゆ柇鏄惁缁戝畾浜嗙綉鍏筹紝鑾峰彇缃戝叧杩滅▼杩炴帴鐨勫姞瀵咾EY
//if (DB_ResidenceData.Instance.CheckWhetherGatewayIsBound())
{
--
Gitblit v1.8.0