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
This handler acts as a health check for a connection. It periodically sends
PingMessage
s,
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final short
static final String
protected final AtomicInteger
-
Constructor Summary
ConstructorsConstructorDescriptionPingPongHandler
(int networkId, Identity identity, short maxRetries) PingPongHandler withretries
retries, until channel is closed. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
PING_PONG_HANDLER
- See Also:
-
maxRetries
protected final short maxRetries -
retries
-
-
Constructor Details
-
PingPongHandler
PingPongHandler withretries
retries, until channel is closed.
-
-
Method Details
-
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
-
channelRead0
- Specified by:
channelRead0
in classio.netty.channel.SimpleChannelInboundHandler<Message>
-