Class NettyUtils


  • public final class NettyUtils
    extends Object
    Some Netty's channels utilities.
    • Method Detail

      • getAttribute

        public static Object getAttribute​(io.netty.channel.ChannelHandlerContext ctx,
                                          io.netty.util.AttributeKey<Object> key)
      • keepAlive

        public static void keepAlive​(io.netty.channel.Channel channel,
                                     int keepAlive)
      • cleanSession

        public static void cleanSession​(io.netty.channel.Channel channel,
                                        boolean cleanSession)
      • cleanSession

        public static boolean cleanSession​(io.netty.channel.Channel channel)
      • clientID

        public static void clientID​(io.netty.channel.Channel channel,
                                    String clientID)
      • clientID

        public static String clientID​(io.netty.channel.Channel channel)
      • userName

        public static void userName​(io.netty.channel.Channel channel,
                                    String username)
      • userName

        public static String userName​(io.netty.channel.Channel channel)
      • validateMessage

        public static io.netty.handler.codec.mqtt.MqttMessage validateMessage​(Object message)
                                                                       throws IOException,
                                                                              ClassCastException
        Validate that the provided message is an MqttMessage and that it does not contain a failed result.
        Parameters:
        message - to be validated
        Returns:
        the casted provided message
        Throws:
        IOException - in case of an fail message this will wrap the root cause
        ClassCastException - if the provided message is no MqttMessage