Package com.tenio.network.netty
Class BaseNettyHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- com.tenio.network.netty.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
-
-
Constructor Summary
Constructors Constructor Description BaseNettyHandler()
-
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 eventprotected void
_exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)
Record the exceptionsprotected 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
-
-
-
-
Method Detail
-
_getConnection
protected Connection _getConnection(io.netty.channel.Channel channel)
Retrieve a connection by its channel- Parameters:
channel
- , seeChannel
- 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, seeChannelHandlerContext
keepPlayerOnDisconnect
- this value can be configured in your configurations, seeBaseConfiguration
. 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, seeChannelHandlerContext
cause
- the exception will occur
-
-