Netty HTTP Server Example
It needs setting up with a few things, first we give it the event loops we created earlier which allows our server to accept and handle connections.
Next is a call to. Netty will creates instances of this class and uses them to accept new connections. Then a call to. This is where interesting things will happen, it sets up the pipeline that accepted connections are handled through. We then start the server by telling it to bind to a port at the local address and call. The initChannel method of this class is called by Netty whenever it receives a new connection.
Each SocketChannel has a pipeline associated with it. You can think of think of the pipeline as an ordered list of handlers with each feeding its output as the input to the next one. There are caveats to this but we can ignore them for now. Looks like on the server side, we don't need channelActive at all. You can add LoggingHandler to your pipeline and it will log if client is active. ChannelRead is called after channelActive and here you can read messages. In channelActive you can initialize some helpful stuff if you need e.