下面列出了怎么用 io.netty.handler.codec.ByteToMessageCodec 的API类实例代码及写法,或者点击链接到github查看源代码。
static void autoAddHttpExtractor(Connection c, String name, ChannelHandler handler){
if (handler instanceof ByteToMessageDecoder
|| handler instanceof ByteToMessageCodec
|| handler instanceof CombinedChannelDuplexHandler) {
String extractorName = name+"$extractor";
if(c.channel().pipeline().context(extractorName) != null){
return;
}
c.channel().pipeline().addBefore(name, extractorName, HTTP_EXTRACTOR);
if(c.isPersistent()){
c.onTerminate().subscribe(null, null, () -> c.removeHandler(extractorName));
}
}
}