Package org.jboss.netty.example.uptime
Class UptimeClientHandler
- java.lang.Object
-
- org.jboss.netty.channel.SimpleChannelUpstreamHandler
-
- org.jboss.netty.example.uptime.UptimeClientHandler
-
- All Implemented Interfaces:
ChannelHandler
,ChannelUpstreamHandler
public class UptimeClientHandler extends SimpleChannelUpstreamHandler
Keep reconnecting to the server while printing out the current uptime and connection attempt status.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ClientBootstrap
bootstrap
private long
startTime
private Timer
timer
-
Constructor Summary
Constructors Constructor Description UptimeClientHandler(ClientBootstrap bootstrap, Timer timer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
Invoked when aChannel
was closed and all its related resources were released.void
channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)
Invoked when aChannel
is open, bound to a local address, and connected to a remote address.void
channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e)
Invoked when aChannel
was disconnected from its remote peer.void
exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
Invoked when an exception was raised by an I/O thread or aChannelHandler
.(package private) java.net.InetSocketAddress
getRemoteAddress()
private void
println(java.lang.String msg)
-
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, messageReceived, writeComplete
-
-
-
-
Field Detail
-
bootstrap
final ClientBootstrap bootstrap
-
timer
private final Timer timer
-
startTime
private long startTime
-
-
Constructor Detail
-
UptimeClientHandler
public UptimeClientHandler(ClientBootstrap bootstrap, Timer timer)
-
-
Method Detail
-
getRemoteAddress
java.net.InetSocketAddress getRemoteAddress()
-
channelDisconnected
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e)
Description copied from class:SimpleChannelUpstreamHandler
Invoked when aChannel
was disconnected from its remote peer.- Overrides:
channelDisconnected
in classSimpleChannelUpstreamHandler
-
channelClosed
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
Description copied from class:SimpleChannelUpstreamHandler
Invoked when aChannel
was closed and all its related resources were released.- Overrides:
channelClosed
in classSimpleChannelUpstreamHandler
-
channelConnected
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)
Description copied from class:SimpleChannelUpstreamHandler
Invoked when aChannel
is open, bound to a local address, and connected to a remote address.
Be aware that this event is fired from within the I/O thread. You should never execute any heavy operation in there as it will block the dispatching to other workers!- Overrides:
channelConnected
in classSimpleChannelUpstreamHandler
-
exceptionCaught
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
Description copied from class:SimpleChannelUpstreamHandler
Invoked when an exception was raised by an I/O thread or aChannelHandler
.- Overrides:
exceptionCaught
in classSimpleChannelUpstreamHandler
-
println
private void println(java.lang.String msg)
-
-