@ChannelHandler.Sharable
public class ConnectionWatchdog
extends io.netty.channel.ChannelInboundHandlerAdapter
ChannelHandler responsible for monitoring the channel and
reconnecting when the connection is lost.| Modifier and Type | Field and Description |
|---|---|
static io.netty.util.AttributeKey<Boolean> |
SHUTDOWN_KEY |
| Constructor and Description |
|---|
ConnectionWatchdog(io.netty.bootstrap.Bootstrap bootstrap,
io.netty.channel.group.ChannelGroup channels)
Create a new watchdog that adds to new connections to the supplied
ChannelGroup
and establishes a new Channel when disconnected, while reconnect is true. |
| Modifier and Type | Method and Description |
|---|---|
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
String |
toString() |
channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredhandlerAdded, handlerRemoved, isSharablepublic static final io.netty.util.AttributeKey<Boolean> SHUTDOWN_KEY
public ConnectionWatchdog(io.netty.bootstrap.Bootstrap bootstrap,
io.netty.channel.group.ChannelGroup channels)
ChannelGroup
and establishes a new Channel when disconnected, while reconnect is true.bootstrap - Configuration for new channels.public void channelActive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelActive in interface io.netty.channel.ChannelInboundHandlerchannelActive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
throws Exception
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in interface io.netty.channel.ChannelInboundHandlerexceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapterExceptionCopyright © 2014–2015. All rights reserved.