0
votes

In my netty client I have a initial pipeline with only a ChannelInboundHandlerAdapter. With this handler I handle the handshake of my protocol. After that I neeed to modify the pipeline for normal use. This means I need to remove the ChannelInboundHandlerAdapter and add LengthFieldPrepender/LengthFieldBasedFrameDecoder, Encoder/Decoder and a Handler.

What is the best way to do this?

1
What have you tried already? See minimal reproducible example.toonarmycaptain

1 Answers

1
votes

The context for your channel handler has the channel. You get the pipeline, and add the new channel handlers in the desired order. Finally, you remove the negotiation handler.

All of this should be done from inside the negotiation channel handler, as its final steps. Operations on a single channel are performed on the event loop (read "thread") for that channel, in a sequential fashion, so there are no race conditions within the channel.