Search in sources :

Example 21 with MqttFixedHeader

use of io.netty.handler.codec.mqtt.MqttFixedHeader in project thingsboard by thingsboard.

the class MqttTransportHandler method createSubAckMessage.

private static MqttSubAckMessage createSubAckMessage(Integer msgId, List<Integer> grantedQoSList) {
    MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(SUBACK, false, AT_MOST_ONCE, false, 0);
    MqttMessageIdVariableHeader mqttMessageIdVariableHeader = MqttMessageIdVariableHeader.from(msgId);
    MqttSubAckPayload mqttSubAckPayload = new MqttSubAckPayload(grantedQoSList);
    return new MqttSubAckMessage(mqttFixedHeader, mqttMessageIdVariableHeader, mqttSubAckPayload);
}
Also used : MqttMessageIdVariableHeader(io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader) MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader) MqttSubAckMessage(io.netty.handler.codec.mqtt.MqttSubAckMessage) MqttSubAckPayload(io.netty.handler.codec.mqtt.MqttSubAckPayload)

Example 22 with MqttFixedHeader

use of io.netty.handler.codec.mqtt.MqttFixedHeader in project thingsboard by thingsboard.

the class MqttTransportHandler method createMqttConnAckMsg.

private MqttConnAckMessage createMqttConnAckMsg(MqttConnectReturnCode returnCode, MqttConnectMessage msg) {
    MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(CONNACK, false, AT_MOST_ONCE, false, 0);
    MqttConnAckVariableHeader mqttConnAckVariableHeader = new MqttConnAckVariableHeader(returnCode, !msg.variableHeader().isCleanSession());
    return new MqttConnAckMessage(mqttFixedHeader, mqttConnAckVariableHeader);
}
Also used : MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader) MqttConnAckVariableHeader(io.netty.handler.codec.mqtt.MqttConnAckVariableHeader) MqttConnAckMessage(io.netty.handler.codec.mqtt.MqttConnAckMessage)

Example 23 with MqttFixedHeader

use of io.netty.handler.codec.mqtt.MqttFixedHeader in project thingsboard by thingsboard.

the class MqttTransportHandler method createUnSubAckMessage.

private MqttMessage createUnSubAckMessage(int msgId) {
    MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(UNSUBACK, false, AT_MOST_ONCE, false, 0);
    MqttMessageIdVariableHeader mqttMessageIdVariableHeader = MqttMessageIdVariableHeader.from(msgId);
    return new MqttMessage(mqttFixedHeader, mqttMessageIdVariableHeader);
}
Also used : MqttMessageIdVariableHeader(io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader) MqttMessage(io.netty.handler.codec.mqtt.MqttMessage) MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader)

Example 24 with MqttFixedHeader

use of io.netty.handler.codec.mqtt.MqttFixedHeader in project thingsboard by thingsboard.

the class MqttTransportHandler method createMqttPubAckMsg.

public static MqttPubAckMessage createMqttPubAckMsg(int requestId) {
    MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(PUBACK, false, AT_MOST_ONCE, false, 0);
    MqttMessageIdVariableHeader mqttMsgIdVariableHeader = MqttMessageIdVariableHeader.from(requestId);
    return new MqttPubAckMessage(mqttFixedHeader, mqttMsgIdVariableHeader);
}
Also used : MqttMessageIdVariableHeader(io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader) MqttFixedHeader(io.netty.handler.codec.mqtt.MqttFixedHeader) MqttPubAckMessage(io.netty.handler.codec.mqtt.MqttPubAckMessage)

Example 25 with MqttFixedHeader

use of io.netty.handler.codec.mqtt.MqttFixedHeader in project thingsboard by thingsboard.

the class MqttTransportAdaptor method createMqttPublishMsg.

default MqttPublishMessage createMqttPublishMsg(MqttDeviceAwareSessionContext ctx, String topic, byte[] payloadInBytes) {
    MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, ctx.getQoSForTopic(topic), false, 0);
    MqttPublishVariableHeader header = new MqttPublishVariableHeader(topic, ctx.nextMsgId());
    ByteBuf payload = ALLOCATOR.buffer();
    payload.writeBytes(payloadInBytes);
    return new MqttPublishMessage(mqttFixedHeader, header, payload);
}
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)

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