ProtocolNegotiators.java 文件源码

java
阅读 29 收藏 0 点赞 0 评论 0

项目:grpc-java 作者:
/**
 * When this channel is registered, we will add all the ChannelHandlers passed into our
 * constructor to the pipeline.
 */
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
  /**
   * This check is necessary as a channel may be registered with different event loops during it
   * lifetime and we only want to configure it once.
   */
  if (handlers != null) {
    for (ChannelHandler handler : handlers) {
      ctx.pipeline().addBefore(ctx.name(), null, handler);
    }
    ChannelHandler handler0 = handlers[0];
    ChannelHandlerContext handler0Ctx = ctx.pipeline().context(handlers[0]);
    handlers = null;
    if (handler0Ctx != null) { // The handler may have removed itself immediately
      if (handler0 instanceof ChannelInboundHandler) {
        ((ChannelInboundHandler) handler0).channelRegistered(handler0Ctx);
      } else {
        handler0Ctx.fireChannelRegistered();
      }
    }
  } else {
    super.channelRegistered(ctx);
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号