use of io.netty.handler.codec.mqtt.MqttFixedHeader in project rocketmq-externals by apache.
the class MessageUtil method getMqttConnackMessage.
public static MqttConnAckMessage getMqttConnackMessage(MqttConnectMessage message, MqttConnectReturnCode returnCode) {
assert message.fixedHeader().messageType() == MqttMessageType.CONNECT;
MqttConnAckVariableHeader variableHeader = new MqttConnAckVariableHeader(returnCode, message.variableHeader().isCleanSession());
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.CONNACK, message.fixedHeader().isDup(), message.fixedHeader().qosLevel(), message.fixedHeader().isRetain(), 0);
return new MqttConnAckMessage(fixedHeader, variableHeader);
}
use of io.netty.handler.codec.mqtt.MqttFixedHeader in project rocketmq-externals by apache.
the class MessageUtil method getMqttPublishMessage.
public static MqttPublishMessage getMqttPublishMessage(Message message, boolean isDup) {
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, isDup, MqttQoS.valueOf(message.getHeaders().get(MQTT_QOS_LEVEL)), Boolean.valueOf(message.getHeaders().get(MQTT_IS_RETAIN)), Integer.valueOf(message.getHeaders().get(MQTT_REMAINING_LENGTH)));
MqttPublishVariableHeader variableHeader = new MqttPublishVariableHeader(message.getHeaders().get(MQTT_TOPIC_NAME), Integer.valueOf(message.getHeaders().get(MQTT_PACKET_ID)));
ByteBuf buf = Unpooled.buffer();
buf.writeBytes((byte[]) message.getPayload());
return new MqttPublishMessage(fixedHeader, variableHeader, buf);
}
use of io.netty.handler.codec.mqtt.MqttFixedHeader in project rocketmq-externals by apache.
the class MessageUtil method getMqttSubackMessage.
public static MqttSubAckMessage getMqttSubackMessage(MqttSubscribeMessage message, MqttSubAckPayload payload) {
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.SUBACK, false, message.fixedHeader().qosLevel(), message.fixedHeader().isRetain(), 0);
MqttMessageIdVariableHeader variableHeader = MqttMessageIdVariableHeader.from(message.variableHeader().messageId());
return new MqttSubAckMessage(fixedHeader, variableHeader, payload);
}
use of io.netty.handler.codec.mqtt.MqttFixedHeader in project rocketmq-externals by apache.
the class MessageUtil method getMqttUnsubackMessage.
public static MqttUnsubAckMessage getMqttUnsubackMessage(MqttUnsubscribeMessage message) {
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.UNSUBACK, message.fixedHeader().isDup(), message.fixedHeader().qosLevel(), message.fixedHeader().isRetain(), 0);
MqttMessageIdVariableHeader variableHeader = MqttMessageIdVariableHeader.from(message.variableHeader().messageId());
return new MqttUnsubAckMessage(fixedHeader, variableHeader);
}
use of io.netty.handler.codec.mqtt.MqttFixedHeader 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);
}
Aggregations