Search in sources :

Example 6 with Message

use of org.apache.rocketmq.iot.common.data.Message in project rocketmq-externals by apache.

the class MessageUtil method getMessage.

public static Message getMessage(MqttMessage mqttMessage) {
    Message message = new Message();
    message.setPayload(mqttMessage);
    switch(mqttMessage.fixedHeader().messageType()) {
        case CONNECT:
            message.setType(Message.Type.MQTT_CONNECT);
            break;
        case CONNACK:
            message.setType(Message.Type.MQTT_CONNACK);
            break;
        case PUBLISH:
            message.setType(Message.Type.MQTT_PUBLISH);
            break;
        case PUBACK:
            message.setType(Message.Type.MQTT_PUBACK);
            break;
        case PUBREC:
            message.setType(Message.Type.MQTT_PUBREC);
            break;
        case PUBREL:
            message.setType(Message.Type.MQTT_PUBREL);
            break;
        case PUBCOMP:
            message.setType(Message.Type.MQTT_PUBCOMP);
        case SUBSCRIBE:
            message.setType(Message.Type.MQTT_SUBSCRIBE);
            break;
        case SUBACK:
            message.setType(Message.Type.MQTT_SUBACK);
            break;
        case UNSUBSCRIBE:
            message.setType(Message.Type.MQTT_UNSUBSCRIBE);
            break;
        case UNSUBACK:
            message.setType(Message.Type.MQTT_UNSUBACK);
            break;
        case PINGREQ:
            message.setType(Message.Type.MQTT_PINGREQ);
            break;
        case PINGRESP:
            message.setType(Message.Type.MQTT_PINGRESP);
            break;
        case DISCONNECT:
            message.setType(Message.Type.MQTT_DISCONNECT);
            break;
        default:
    }
    return message;
}
Also used : MqttPubAckMessage(io.netty.handler.codec.mqtt.MqttPubAckMessage) MqttPublishMessage(io.netty.handler.codec.mqtt.MqttPublishMessage) MqttSubscribeMessage(io.netty.handler.codec.mqtt.MqttSubscribeMessage) MqttConnectMessage(io.netty.handler.codec.mqtt.MqttConnectMessage) MqttSubAckMessage(io.netty.handler.codec.mqtt.MqttSubAckMessage) MqttConnAckMessage(io.netty.handler.codec.mqtt.MqttConnAckMessage) MqttMessage(io.netty.handler.codec.mqtt.MqttMessage) MqttUnsubAckMessage(io.netty.handler.codec.mqtt.MqttUnsubAckMessage) Message(org.apache.rocketmq.iot.common.data.Message) MqttUnsubscribeMessage(io.netty.handler.codec.mqtt.MqttUnsubscribeMessage)

Aggregations

Message (org.apache.rocketmq.iot.common.data.Message)6 MqttMessage (io.netty.handler.codec.mqtt.MqttMessage)3 MqttConnectMessage (io.netty.handler.codec.mqtt.MqttConnectMessage)2 Test (org.junit.Test)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 MqttConnAckMessage (io.netty.handler.codec.mqtt.MqttConnAckMessage)1 MqttPubAckMessage (io.netty.handler.codec.mqtt.MqttPubAckMessage)1 MqttPublishMessage (io.netty.handler.codec.mqtt.MqttPublishMessage)1 MqttSubAckMessage (io.netty.handler.codec.mqtt.MqttSubAckMessage)1 MqttSubscribeMessage (io.netty.handler.codec.mqtt.MqttSubscribeMessage)1 MqttUnsubAckMessage (io.netty.handler.codec.mqtt.MqttUnsubAckMessage)1 MqttUnsubscribeMessage (io.netty.handler.codec.mqtt.MqttUnsubscribeMessage)1 IdleStateEvent (io.netty.handler.timeout.IdleStateEvent)1 Client (org.apache.rocketmq.iot.connection.client.Client)1 MqttClient (org.apache.rocketmq.iot.protocol.mqtt.data.MqttClient)1