To implement my project I decided to use netty The application must act according to this algorithm:
- The client connects to the server and all the time sends the necessary data for the update.
- The server processes this data and sends all changes with a broadcast message for all clients (something like UDP)
The problem is how to implement this? If we add a new Handler to our PipeLine and inherit it from SimpleChannelInboundHandler, then only the following methods will be available:
- channelActive - when you connect a user, we do something
- channelRead0 - when we receive a message, we do something
- exceptionCaught - close the connection.
And yet, we can not insert here any kind of broadcasting. The solution would be if the client constantly sends messages with an update request, then we will be able to send updates to channelRead0 for a specific client, but this implementation is not suitable.
While searching for an answer, I came across this question, which suggested that it is necessary to use the ChannelGroup.
How to implement something like myServer.sendBroadcast ("message"); ?