Class PingPongHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

    public class PingPongHandler
    extends io.netty.channel.SimpleChannelInboundHandler<Message>
    This handler acts as a health check for a connection. It periodically sends PingMessages, which must be answered with a PongMessage. When a configured threshold of messages is not answered, the connection is considered unhealthy and is closed.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Constructor Summary

      Constructors 
      Constructor Description
      PingPongHandler()
      PingPongHandler with 3 retries, until channel is closed.
      PingPongHandler​(short maxRetries)
      PingPongHandler with retries retries, until channel is closed.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void channelRead0​(io.netty.channel.ChannelHandlerContext ctx, Message msg)  
      void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx, Object evt)  
      • Methods inherited from class io.netty.channel.SimpleChannelInboundHandler

        acceptInboundMessage, channelRead
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded, handlerRemoved
    • Constructor Detail

      • PingPongHandler

        public PingPongHandler()
        PingPongHandler with 3 retries, until channel is closed.
      • PingPongHandler

        public PingPongHandler​(short maxRetries)
        PingPongHandler with retries retries, until channel is closed.
    • Method Detail

      • userEventTriggered

        public void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx,
                                       Object evt)
                                throws Exception
        Specified by:
        userEventTriggered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • channelRead0

        protected void channelRead0​(io.netty.channel.ChannelHandlerContext ctx,
                                    Message msg)
        Specified by:
        channelRead0 in class io.netty.channel.SimpleChannelInboundHandler<Message>