【发布时间】:2021-01-28 20:29:19
【问题描述】:
我正在努力将使用 Netty 3 的应用程序升级到 Netty 4。目前许多处理程序的代码如下所示:
public class SomeHandler extends SimpleChannelUpstreamHandler {
@Override
public void channelOpen(final ChannelHandlerContext ctx, final ChannelStateEvent e) {
// do stuff with input
// ....
// then call the sendUpstream method
ctx.sendUpstream(e);
}
}
我正在寻找如何将其转换为 Netty 4。我看到 ChannelOutboundHandlerAdapter 现在替换了 SimpleChannelUpstreamHandler,但仍有几个问题:
-
ChannelStateEvent在 Netty 4 中不再可用,现在接收通道事件的机制是什么? -
ctx.sendUpstream(e)在那里做什么,如何在 Netty 4 中复制?
【问题讨论】: