public class NettyServerHandler extends io.netty.channel.SimpleChannelInboundHandler<RpcRequest>
| 构造器和说明 |
|---|
NettyServerHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext ctx,
RpcRequest msg)
服务器的监听通道读取方法是 多线程的,这样能应对多个 客户端的并发访问
|
void |
channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
void |
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
监听 所有 客户端 发送的 心跳包
IdleState.READER_IDLE 时间内 服务端 没有 读操作(即客户端没有写操作,心跳包发送失败,失去连接)
触发方法执行,关闭 服务端 与 客户端的 通道 channel
|
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregisteredensureNotSharable, handlerAdded, handlerRemoved, isSharableprotected void channelRead0(io.netty.channel.ChannelHandlerContext ctx,
RpcRequest msg)
throws Exception
channelRead0 在类中 io.netty.channel.SimpleChannelInboundHandler<RpcRequest>ctx - 通道处理上下文msg - 请求包Exceptionpublic void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelWritabilityChanged 在接口中 io.netty.channel.ChannelInboundHandlerchannelWritabilityChanged 在类中 io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
throws Exception
exceptionCaught 在接口中 io.netty.channel.ChannelHandlerexceptionCaught 在接口中 io.netty.channel.ChannelInboundHandlerexceptionCaught 在类中 io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
throws Exception
userEventTriggered 在接口中 io.netty.channel.ChannelInboundHandleruserEventTriggered 在类中 io.netty.channel.ChannelInboundHandlerAdapterctx - evt - ExceptionCopyright © 2025. All rights reserved.