Class BaseNettyHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
    Direct Known Subclasses:
    NettyDatagramHandler, NettySocketHandler, NettyWSHandler

    public abstract class BaseNettyHandler
    extends io.netty.channel.ChannelInboundHandlerAdapter
    Use Netty to handle message. Base on the messages' content. You can handle your own logic here.
    Author:
    kong
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void _channelInactive​(io.netty.channel.ChannelHandlerContext ctx, boolean keepPlayerOnDisconnect)
      When a client is disconnected from your server for any reason, you can handle it in this event
      protected void _exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)
      Record the exceptions
      protected Connection _getConnection​(io.netty.channel.Channel channel)
      Retrieve a connection by its channel
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelInactive, channelRead, 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
    • Constructor Detail

      • BaseNettyHandler

        public BaseNettyHandler()
    • Method Detail

      • _getConnection

        protected Connection _getConnection​(io.netty.channel.Channel channel)
        Retrieve a connection by its channel
        Parameters:
        channel - , see Channel
        Returns:
        a connection
      • _channelInactive

        protected void _channelInactive​(io.netty.channel.ChannelHandlerContext ctx,
                                        boolean keepPlayerOnDisconnect)
        When a client is disconnected from your server for any reason, you can handle it in this event
        Parameters:
        ctx - the channel, see ChannelHandlerContext
        keepPlayerOnDisconnect - this value can be configured in your configurations, see BaseConfiguration. If the value is set to true, when the client is disconnected, its player can be held for an interval time (you can configure this interval time in your configurations)
      • _exceptionCaught

        protected void _exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                        java.lang.Throwable cause)
        Record the exceptions
        Parameters:
        ctx - the channel, see ChannelHandlerContext
        cause - the exception will occur