From 66c72ee19b9e3543537621b8dd25685c9b5c03c4 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 02 八月 2022 14:05:30 +0800 Subject: [PATCH] RGB色盘优化,第三方平台对接功能 --- HDL_ON/DAL/Mqtt/MqttClient.cs | 90 ++++++++++++++++++++++++++++++++------------- 1 files changed, 64 insertions(+), 26 deletions(-) diff --git a/HDL_ON/DAL/Mqtt/MqttClient.cs b/HDL_ON/DAL/Mqtt/MqttClient.cs index b0c260f..ea5e472 100644 --- a/HDL_ON/DAL/Mqtt/MqttClient.cs +++ b/HDL_ON/DAL/Mqtt/MqttClient.cs @@ -205,6 +205,7 @@ QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }; + #region 鏁版嵁鏇存柊鎺ㄩ�佷富棰� //appHomeRefresh锛氫綇瀹呮暟鎹埛鏂伴�氱煡--鏉ㄦ稕 var appHomeRefresh = new MqttTopicFilter() @@ -273,6 +274,49 @@ } } } + + /// <summary> + /// 璁㈤槄缁戝畾绗笁鏂筰ot璐﹀彿缁撴灉 + /// </summary> + /// <returns></returns> + public static async Task<bool> SubscribeAsync3tyIotbind() + { + var topicFilter = new MqttTopicFilter() + { + Topic = $"/user/{UserInfo.Current.ID}/app/third/bind/send", + QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce + }; + var result = await RemoteMqttClient.SubscribeAsync(topicFilter); + if (result.Items[0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS0) + { + Utlis.WriteLine("璁㈤槄缁戝畾绗笁鏂筰ot璐﹀彿缁撴灉鎴愬姛锛�"); + return true; + } + return false; + } + /// <summary> + /// 鍙栨秷璁㈤槄缁戝畾绗笁鏂筰ot璐﹀彿缁撴灉 + /// </summary> + /// <returns></returns> + public static async Task<bool> UnsubscribeAsync3tyIotbind() + { + string[] strs = new string[] { + $"/user/{UserInfo.Current.ID}/app/third/bind/send" + }; + + var result = await RemoteMqttClient.UnsubscribeAsync(strs); + + if (result.Items[0].ReasonCode == MQTTnet.Client.Unsubscribing.MqttClientUnsubscribeResultCode.Success) + { + Utlis.WriteLine("鍙栨秷璁㈤槄缁戝畾绗笁鏂筰ot璐﹀彿缁撴灉鎴愬姛锛�"); + return true; + } + return false; + } + /// <summary> + /// 缁戝畾绗笁鏂瑰钩鍙版帴鏀跺洖璋冧簨浠� + /// </summary> + public static Action Bind3tyIotAction; /// <summary> /// 鍚姩杩滅▼Mqtt @@ -352,8 +396,14 @@ //鏂版尋涓嬬嚎涓婚鏂规 鏀跺埌鎸や笅绾夸富棰� ReceiveNotifySqueezeAsync(mMes); } + //缁戝畾绗笁鏂瑰钩鍙扮粨鏋滈�氱煡 + else if(topic == $"/user/{UserInfo.Current.ID}/app/third/bind/send") + { + var revString = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); + Bind3tyIotAction?.Invoke(); + } //璁惧鍦ㄧ嚎绂荤嚎鐘舵�佹帹閫� - else if(topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online") + else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online") { try { @@ -373,7 +423,7 @@ //} } - catch(Exception ex) + catch (Exception ex) { } @@ -504,7 +554,8 @@ } HomePage.LoadEvent_RefreshSecurityStatus(); } - }catch(Exception ex) + } + catch (Exception ex) { MainPage.Log($"瀹夐槻杩滅▼淇℃伅寮傚父:{ex.Message}"); } @@ -516,29 +567,16 @@ else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/property/send") { - if (Control.Ins.GatewayOnline_Local)//鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞� - { - if (FunctionList.List.OtherBrandFunction.Count == 0) - { - MainPage.Log($"A鍗忚鏇存柊鐘舵��:鏈湴閾炬帴锛岄櫎浜嗘秱楦﹁澶囨暟鎹箣澶栫殑浜戠鏁版嵁涓嶅鐞�..."); - return; - } - else - { - var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); - var revString = Encoding.UTF8.GetString(bytes); - MainPage.Log($"mqtt 鐘舵�佹洿鏂�:{revString}"); - Control.Ins.UpdataFunctionStatus(revString, null, true); - //Control.Ins.MsgInfoList.Add($"mqtt 鐘舵�佹洿鏂�:{revString}"); - //Control.Ins.MsgInfoList.Add(revString + "\r\n"); - //if (FunctionList.List.OtherBrandFunction.Find((obj) => obj.sid == updateTemp.sid) == null) - //{ - // return; - //} - } - } - - + var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); + var revString = Encoding.UTF8.GetString(bytes); + MainPage.Log($"mqtt 鐘舵�佹洿鏂�:{revString}"); + Control.Ins.UpdataFunctionStatus(revString, null, true); + //Control.Ins.MsgInfoList.Add($"mqtt 鐘舵�佹洿鏂�:{revString}"); + //Control.Ins.MsgInfoList.Add(revString + "\r\n"); + //if (FunctionList.List.OtherBrandFunction.Find((obj) => obj.sid == updateTemp.sid) == null) + //{ + // return; + //} } //涓�绔彛鏁版嵁瑙f瀽 else -- Gitblit v1.8.0