| | |
| | | try { |
| | | if (!isSubscribeTopicSuccess) { |
| | | |
| | | |
| | | var topicFilterCommon = new TopicFilter () { |
| | | Topic = $"/BusGateWayToClient/{CurRemoteMACInfo.macMark}/Common/#", |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce |
| | |
| | | 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) { |
| | | |
| | |
| | | //表示后面将进行连接 |
| | | |
| | | #region 初始化远程Mqtt |
| | | //2020-06-22 增加 |
| | | RemoteMqttClient = new MqttFactory ().CreateMqttClient (); |
| | | |
| | | //(3)当[连接云端的Mqtt成功后]或者[以及后面App通过云端Mqtt转发数据给网关成功后],处理接收到云端数据包响应时在mqttServerClient_ApplicationMessageReceived这个方法处理 |
| | | if (RemoteMqttClient.ApplicationMessageReceivedHandler == null) { |
| | | RemoteMqttClient.UseApplicationMessageReceivedHandler (async (e) => { |