Class ClientSession
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
crow.game.examples.pingpong.client.ClientSession
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class ClientSession
extends io.netty.channel.ChannelInboundHandlerAdapter
This contains the state and netty behavior of the ping pong client.
We use scheduleAtFixedRate to trigger pings from the client to server as a keepalive. The HA rathena code performs application-level ping/pong so this is an example for eventual usage in that module.
We send 5 pings in an interval and then cancel the recurring task them which should trigger an idle event on the server, and the server will kill the connection. This helps test a few assumptions and designs that will go into the main server(s).
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intstatic final org.slf4j.Loggerprotected ScheduledFuture<?> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) voidsendPing(io.netty.channel.ChannelHandlerContext ctx) Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
logger
public static final org.slf4j.Logger logger -
count
protected int count -
pinger
-
-
Constructor Details
-
ClientSession
public ClientSession()
-
-
Method Details
-
sendPing
public void sendPing(io.netty.channel.ChannelHandlerContext ctx) -
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter
-