use of io.netty.handler.codec.mqtt.MqttUnsubscribePayload in project rocketmq-externals by apache.
the class MqttUnsubscribeMessageHandlerTest method getMqttUnsubscribeMessage.
private MqttUnsubscribeMessage getMqttUnsubscribeMessage() {
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.UNSUBSCRIBE, false, MqttQoS.AT_MOST_ONCE, false, 0);
MqttMessageIdVariableHeader variableHeader = MqttMessageIdVariableHeader.from(1);
List<String> topicFilters = new ArrayList<>();
MqttUnsubscribePayload payload = new MqttUnsubscribePayload(topicFilters);
return new MqttUnsubscribeMessage(fixedHeader, variableHeader, payload);
}
use of io.netty.handler.codec.mqtt.MqttUnsubscribePayload in project thingsboard by thingsboard.
the class MqttClientImpl method checkSubscribtions.
private void checkSubscribtions(String topic, Promise<Void> promise) {
if (!(this.subscriptions.containsKey(topic) && this.subscriptions.get(topic).size() != 0) && this.serverSubscriptions.contains(topic)) {
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.UNSUBSCRIBE, false, MqttQoS.AT_LEAST_ONCE, false, 0);
MqttMessageIdVariableHeader variableHeader = getNewMessageId();
MqttUnsubscribePayload payload = new MqttUnsubscribePayload(Collections.singletonList(topic));
MqttUnsubscribeMessage message = new MqttUnsubscribeMessage(fixedHeader, variableHeader, payload);
MqttPendingUnsubscription pendingUnsubscription = new MqttPendingUnsubscription(promise, topic, message, () -> !pendingServerUnsubscribes.containsKey(variableHeader.messageId()));
this.pendingServerUnsubscribes.put(variableHeader.messageId(), pendingUnsubscription);
pendingUnsubscription.startRetransmissionTimer(this.eventLoop.next(), this::sendAndFlushPacket);
this.sendAndFlushPacket(message);
} else {
promise.setSuccess(null);
}
}
Aggregations