Class PingPongHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.SimpleChannelInboundHandler<Message>
-
- org.drasyl.peer.connection.handler.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 sendsPingMessage
s, which must be answered with aPongMessage
. When a configured threshold of messages is not answered, the connection is considered unhealthy and is closed.
-
-
Field Summary
Fields Modifier and Type Field Description protected short
maxRetries
static String
PING_PONG_HANDLER
protected AtomicInteger
retries
-
Constructor Summary
Constructors Constructor Description PingPongHandler()
PingPongHandler with3
retries, until channel is closed.PingPongHandler(short maxRetries)
PingPongHandler withretries
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
-
-
-
-
Field Detail
-
PING_PONG_HANDLER
public static final String PING_PONG_HANDLER
- See Also:
- Constant Field Values
-
maxRetries
protected final short maxRetries
-
retries
protected final AtomicInteger retries
-
-
Method Detail
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception
- Specified by:
userEventTriggered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
userEventTriggered
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
-