@ChannelHandler.Sharable
public class ConnectionWatchdog
extends io.netty.channel.ChannelInboundHandlerAdapter
ChannelHandler
responsible for monitoring the channel and
reconnecting when the connection is lost.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, userEventTriggered
handlerAdded, handlerRemoved, isSharable
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.ChannelInboundHandler
channelActive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelInactive
in interface io.netty.channel.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
Copyright © 2014. All rights reserved.