Example usage for io.netty.handler.codec.mqtt MqttSubscribeMessage toString

List of usage examples for io.netty.handler.codec.mqtt MqttSubscribeMessage toString

Introduction

In this page you can find the example usage for io.netty.handler.codec.mqtt MqttSubscribeMessage toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:net.anyflow.lannister.packetreceiver.SubscribeReceiver.java

License:Apache License

@Override
protected void channelRead0(ChannelHandlerContext ctx, MqttSubscribeMessage msg) throws Exception {
    logger.debug("packet incoming [message={}]", msg.toString());

    Session session = Session.NEXUS.get(ctx.channel().id());
    if (session == null) {
        logger.error("None exist session message [message={}]", msg.toString());

        ctx.channel().disconnect().addListener(ChannelFutureListener.CLOSE).addListener(fs -> // [MQTT-4.8.0-1]
        Plugins.SELF.get(DisconnectEventListener.class).disconnected(new AbnormalDisconnectEventArgs()));
        return;/*from ww w .  ja v  a  2s  . co  m*/
    }

    session.setLastIncomingTime(new Date());

    List<MqttTopicSubscription> topicSubs = msg.payload().topicSubscriptions();

    if (topicSubs == null || topicSubs.isEmpty()) {
        session.dispose(true); // [MQTT-4.8.0-1]
        return;
    }

    // TODO multiple sub checking (granted QoS)
    Map.Entry<List<Integer>, Map<String, TopicSubscription>> returns = generateReturns(topicSubs);
    List<Integer> grantedQoss = returns.getKey();
    Map<String, TopicSubscription> topicSubscriptions = returns.getValue();

    if (!executePlugins(session, topicSubscriptions.values())) {
        return;
    }

    session.topicSubscriptions().putAll(topicSubscriptions);

    session.send(MessageFactory.suback(msg.variableHeader().messageId(), grantedQoss)); // [MQTT-2.3.1-7],[MQTT-2.3.1-7],[MQTT-3.8.4-1],[MQTT-3.8.4-2]

    sendRetainedMessage(session, topicSubscriptions);

    publishStatic$Sys(session, topicSubscriptions.values());

    // TODO [MQTT-3.3.1-7]
}