2
votes

I want to create a client/server system where I can send objects and commands to the server. I already found out how to send objects (json) and how to use an echo server.

However, the echo example only had one type of message, namely one string, being used. How do I implement a system where I have different kind of messages for different occasions?

Edit: Having read more about handlers and pipelines, I can now ask more precisly what I need: Is it possible to add more than one pipeline to a server or do I have to create a new server with a new port for every use case?

1
You can have different pipelines for each channel. You can also manipulate each pipeline dynamically.jlunavtgrad
How? What is the key word I have to look for?user1406177
The pipeline is initialized by a ChannelInitializer. If you create your own you can add some logic to set the pipeline up like you need. Any time after that you can use the context to get the pipeline and add/remove any handlers you want.jlunavtgrad

1 Answers

5
votes

It is currently not supported to add more then one ChannelPipeline. We plan to support "nested" pipelines at some point but not sure when exactly. For now you could modify the pipeline on the fly to meet your needs.

Check out the PortUnification example which does the same: https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/portunification/PortUnificationServerHandler.java