PietH896
PietH896

Reputation: 58

Netty - Other pipeline for handshake?

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?

Upvotes: 0

Views: 261

Answers (1)

Bob Dalgleish
Bob Dalgleish

Reputation: 8227

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.

Upvotes: 1

Related Questions