Search in sources :

Example 11 with MqttFixedHeader

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);
}
Also used : MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader) MqttConnAckVariableHeader(io.netty.handler.codec.mqtt.MqttConnAckVariableHeader) MqttConnAckMessage(io.netty.handler.codec.mqtt.MqttConnAckMessage)

Example 12 with MqttFixedHeader

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);
}
Also used : MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader) MqttPublishMessage(io.netty.handler.codec.mqtt.MqttPublishMessage) MqttPublishVariableHeader(io.netty.handler.codec.mqtt.MqttPublishVariableHeader) ByteBuf(io.netty.buffer.ByteBuf)

Example 13 with MqttFixedHeader

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);
}
Also used : MqttMessageIdVariableHeader(io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader) MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader) MqttSubAckMessage(io.netty.handler.codec.mqtt.MqttSubAckMessage)

Example 14 with MqttFixedHeader

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);
}
Also used : MqttMessageIdVariableHeader(io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader) MqttUnsubAckMessage(io.netty.handler.codec.mqtt.MqttUnsubAckMessage) MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader)

Example 15 with MqttFixedHeader

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);
}
Also used : MqttMessageIdVariableHeader(io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader) MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader) MqttUnsubscribeMessage(io.netty.handler.codec.mqtt.MqttUnsubscribeMessage) ArrayList(java.util.ArrayList) MqttUnsubscribePayload(io.netty.handler.codec.mqtt.MqttUnsubscribePayload)

Aggregations

MqttFixedHeader (io.netty.handler.codec.mqtt.MqttFixedHeader)43 MqttPublishMessage (io.netty.handler.codec.mqtt.MqttPublishMessage)13 MqttPublishVariableHeader (io.netty.handler.codec.mqtt.MqttPublishVariableHeader)12 MqttMessage (io.netty.handler.codec.mqtt.MqttMessage)11 MqttMessageIdVariableHeader (io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader)11 ByteBuf (io.netty.buffer.ByteBuf)6 MqttConnectMessage (io.netty.handler.codec.mqtt.MqttConnectMessage)6 MqttConnectPayload (io.netty.handler.codec.mqtt.MqttConnectPayload)6 MqttConnectVariableHeader (io.netty.handler.codec.mqtt.MqttConnectVariableHeader)6 MqttConnAckMessage (io.netty.handler.codec.mqtt.MqttConnAckMessage)4 MqttConnAckVariableHeader (io.netty.handler.codec.mqtt.MqttConnAckVariableHeader)4 MqttSubscribeMessage (io.netty.handler.codec.mqtt.MqttSubscribeMessage)4 MqttSubscribePayload (io.netty.handler.codec.mqtt.MqttSubscribePayload)4 MqttSubAckMessage (io.netty.handler.codec.mqtt.MqttSubAckMessage)3 MqttUnsubscribeMessage (io.netty.handler.codec.mqtt.MqttUnsubscribeMessage)3 MqttUnsubscribePayload (io.netty.handler.codec.mqtt.MqttUnsubscribePayload)3 ChannelFuture (io.netty.channel.ChannelFuture)2 MqttPubAckMessage (io.netty.handler.codec.mqtt.MqttPubAckMessage)2 MqttQoS (io.netty.handler.codec.mqtt.MqttQoS)2 MqttSubAckPayload (io.netty.handler.codec.mqtt.MqttSubAckPayload)2