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

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    static final org.slf4j.Logger
     
    protected ScheduledFuture<?>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
     
    void
    sendPing(io.netty.channel.ChannelHandlerContext ctx)
     

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    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

    • logger

      public static final org.slf4j.Logger logger
    • count

      protected int count
    • pinger

      protected ScheduledFuture<?> 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:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter