Netty源码解析-pipeline

1、netty如何判断channelHandler的类型

AbstractChannelHandlerContext构造器需要传入时inbound还是outbound处理器

2、添加channelHandler应该遵循什么规则

3、不同的触发方式有什么区别

pipeline的初始化

  pipeline在创建Channel的时候被创建,一个channel对应一个pipeline对象,会创建head和tail两大节点组成双向链表。

  pipeline的数据结构ChannelHandlerContext,channelHandlerContext继承AttributeMap和ChannelInboundInvoker和ChannelOutboundInvoker

  pipeline的两大哨兵head和tail,tail注意处理exception和未处理的消息,属于inbound,head属于outbound,重点channelActive方法,主要时将事件传播和读写操作。

添加和删除channelHandler

  判断是否重复添加

  创建节点并添加列表

  回调添加完成事件

事件和异常的传播

猜你喜欢

转载自www.cnblogs.com/xiaofeiyang/p/12682533.html