Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

netty4 - What is the replacement for ChannelHandlerContext.sendUpstream in Netty 4

I am working on upgrading an application using Netty 3 to Netty 4. A lot of the handlers currently have code that look like this:

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);
 }

}

I am looking how to convert this to Netty 4. I see that ChannelOutboundHandlerAdapter replaces SimpleChannelUpstreamHandler now, but still couple of questions:

  1. ChannelStateEvent is no longer available in Netty 4, what is the mechanism to receive channel events now?
  2. What is ctx.sendUpstream(e) doing there, and how can that be replicated in Netty 4?
question from:https://stackoverflow.com/questions/65934842/what-is-the-replacement-for-channelhandlercontext-sendupstream-in-netty-4

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you would override channelActive(...) in this case and call ctx.fireChannelActive() as a replacement for sendUpstream(...)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...