From b6655c930866fadf3275587f4c692aa658bd9b21 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 24 六月 2020 10:57:07 +0800 Subject: [PATCH] 2020-06-24 1. 修改网络请求方法,改为HttpWebRequest支持自定义超时时间,默认10S。 2.后台回前台,超过20S断开远程重新连接。 --- Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs index 06bf05b..18c142a 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs @@ -100,6 +100,7 @@ try { if (!isSubscribeTopicSuccess) { + var topicFilterCommon = new TopicFilter () { Topic = $"/BusGateWayToClient/{CurRemoteMACInfo.macMark}/Common/#", QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce @@ -123,12 +124,30 @@ QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce }; - + var topicFilters = new TopicFilter [] { topicFilterCommon, topicFilterGateWayInfoChange, topicFilterNotifySqueeze, topicFilterNotifyGateWayOffline }; var result = await RemoteMqttClient.SubscribeAsync (topicFilters); if (result.Items [0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS2) { isSubscribeTopicSuccess = true; } + + ////2020-06-22 閫氱敤涓婚 + //var topicFilterMacMark = new TopicFilter () { + // Topic = $"/BusGateWayToClient/{CurRemoteMACInfo.macMark}/#", + // QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce + //}; + + ////鎸や笅绾夸富棰� + //var topicFilterNotifySqueeze = new TopicFilter () { + // Topic = $"/BusGateWayToClient/{mMqttInfo.connEmqClientId}/Push/NotifySqueeze", + // QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce + //}; + + //var topicFilters = new TopicFilter [] { topicFilterMacMark, topicFilterNotifySqueeze }; + //var result = await RemoteMqttClient.SubscribeAsync (topicFilters); + //if (result.Items [0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS2) { + // isSubscribeTopicSuccess = true; + //} } } catch (Exception ex) { @@ -192,6 +211,9 @@ //琛ㄧず鍚庨潰灏嗚繘琛岃繛鎺� #region 鍒濆鍖栬繙绋婱qtt + //2020-06-22 澧炲姞 + RemoteMqttClient = new MqttFactory ().CreateMqttClient (); + //(3)褰揫杩炴帴浜戠鐨凪qtt鎴愬姛鍚嶿鎴栬�匸浠ュ強鍚庨潰App閫氳繃浜戠Mqtt杞彂鏁版嵁缁欑綉鍏虫垚鍔熷悗],澶勭悊鎺ユ敹鍒颁簯绔暟鎹寘鍝嶅簲鏃跺湪mqttServerClient_ApplicationMessageReceived杩欎釜鏂规硶澶勭悊 if (RemoteMqttClient.ApplicationMessageReceivedHandler == null) { RemoteMqttClient.UseApplicationMessageReceivedHandler (async (e) => { -- Gitblit v1.8.0