/** * The {@link Channel} of the {@link ChannelHandlerContext} was registered with its {@link EventLoop} */ voidchannelRegistered(ChannelHandlerContext ctx)throws Exception;
/** * The {@link Channel} of the {@link ChannelHandlerContext} was unregistered from its {@link EventLoop} */ voidchannelUnregistered(ChannelHandlerContext ctx)throws Exception;
/** * The {@link Channel} of the {@link ChannelHandlerContext} is now active */ // 连接被建立并准备进行通信时被调用 voidchannelActive(ChannelHandlerContext ctx)throws Exception;
/** * The {@link Channel} of the {@link ChannelHandlerContext} was registered is now inactive and reached its * end of lifetime. */ voidchannelInactive(ChannelHandlerContext ctx)throws Exception;
/** * Invoked when the current {@link Channel} has read a message from the peer. */ // 读取当前channel的消息 voidchannelRead(ChannelHandlerContext ctx, Object msg)throws Exception;
/** * Invoked when the last message read by the current read operation has been consumed by * {@link #channelRead(ChannelHandlerContext, Object)}. If {@link ChannelOption#AUTO_READ} is off, no further * attempt to read an inbound data from the current {@link Channel} will be made until * {@link ChannelHandlerContext#read()} is called. */ voidchannelReadComplete(ChannelHandlerContext ctx)throws Exception;
/** * Gets called if an user event was triggered. */ voiduserEventTriggered(ChannelHandlerContext ctx, Object evt)throws Exception;
/** * Gets called once the writable state of a {@link Channel} changed. You can check the state with * {@link Channel#isWritable()}. */ voidchannelWritabilityChanged(ChannelHandlerContext ctx)throws Exception;
/** * Gets called if a {@link Throwable} was thrown. */ // 当出现异常时调用该方法 @Override @SuppressWarnings("deprecation") voidexceptionCaught(ChannelHandlerContext ctx, Throwable cause)throws Exception; }