提交 239a8495 编写于 作者: 如梦技术's avatar 如梦技术 🐛

mqtt-client 优化订阅 reasonCodes 判断。

上级 ceb9d85c
......@@ -122,8 +122,26 @@ public class DefaultMqttClientProcessor implements IMqttClientProcessor {
if (paddingSubscribe == null) {
return;
}
String topicFilter = paddingSubscribe.getTopicFilter();
MqttSubAckPayload subAckPayload = message.payload();
List<Integer> reasonCodes = subAckPayload.reasonCodes();
// reasonCodes 为空
if (reasonCodes.isEmpty()) {
logger.error("MqttClient topicFilter:{} subscribe failed reasonCode is empty messageId:{}", topicFilter, messageId);
paddingSubscribe.onSubAckReceived();
clientStore.removePaddingSubscribe(messageId);
return;
}
// reasonCodes 范围
Integer qos = reasonCodes.get(0);
if (qos == null || qos < 0 || qos > 2) {
logger.error("MqttClient topicFilter:{} subscribe failed reasonCodes:{} messageId:{}", topicFilter, reasonCodes, messageId);
paddingSubscribe.onSubAckReceived();
clientStore.removePaddingSubscribe(messageId);
return;
}
if (logger.isInfoEnabled()) {
logger.info("MQTT Topic:{} successfully subscribed messageId:{}", paddingSubscribe.getTopicFilter(), messageId);
logger.info("MQTT Topic:{} successfully subscribed messageId:{}", topicFilter, messageId);
}
paddingSubscribe.onSubAckReceived();
clientStore.removePaddingSubscribe(messageId);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册