Handler
Handler
SimpleChannelInboundHandler
ChannelInboundHandlerAdapter which allows to explicit only handle a specific type of messages.
只允许显式地处理特定类型的消息
ChannelInboundHandlerAdapter
Pipeline
HttpServerCodec 请求解码和返回编码组合
A combination(组合) of HttpRequestDecoder and HttpResponseEncoder which enables easier server side HTTP implementation.
HttpRequestDecoder和HttpResponseEncoder的组合,使服务器端更容易实现HTTP
LengthFieldBasedFrameDecoder
LengthFieldPrepender
StringDecoder&StringEncoder
DelimiterBasedFrameDecoder 分隔符
A decoder that splits the received ByteBufs by one or more delimiters. It is particularly useful for decoding the frames which ends with a delimiter such as Delimiters or Delimiters newline characters.
解码器将收到的ByteBufs通过一个或者更多的分隔符进行切割。他对于解码结束的帧特别有用诸如分隔符和分隔换行符
IdleStateHandler 空闲检测
Triggers an IdleStateEvent when a Channel has not performed read, write, or both operation for a while.
当Channel一段时间内没有触发读和写操作触发IdleStateEvent
通过继承ChannelInboudHandlerAdapter重写userEventTriggered捕获异常
1 |
// 加入handler到pipeline |
LoggingHandler 日志框架
A ChannelHandler that logs all events using a logging framework. By default, all events are logged at DEBUG level.
使用日志框架记录所有事件日志的ChannelHandler。默认所有事件都使用debug等级
1 |
ServerBootstrap serverBootstrap = new ServerBootstrap(); |