java - 写作时是否可以跳过多个ChannelHandler?
问题描述
我试图在我的写入管道中跳过多个 ChannelHandler,以便发送一个小的调试 ByteBuf。我知道您可以根据对象在同一管道中开发多个路径,但为此我只想在管道的最后快速转储此 ByteBuf。例如:
管道(输出):
Base -> Encoder -> Batcher -> Encrypter -> Frame length appender
所以我想从 Base 一直到我的 Frame length appender。
解决方案
你可以这样做,但我真的不推荐它。最好让您ChannelHandler
根据消息类型做正确的事情。
这就是说这样的事情会做到这一点:
ChannelHandler context = channel.pipeline().context(Encrypter.class);
context.write(msg);
推荐阅读
- python - 金融传染(流行病传播)模型遇到问题
- java - 在初始化之外禁用 JButton
- python - 在 Python 中定义额外变量会导致错误
- android - 应用启动时未调用 FirebaseMessagingService
- javascript - 如何将事件监听器添加到新添加的元素?
- python - 如何使多个目录的 SQLite 数据库目录动态路径?
- javascript - 如何在 Wicket 中重新编码 ajax 行为或阻止请求
- android - 从画廊返回后,不在 Fragment 中调用 onActivityResult
- javascript - 当前时间最接近半小时与下一小时时间
- javascript - 有没有办法访问 ckeditor 元素的原始属性?