I previously worked at workerman php to create a websocket server, but since I often work on java, I decided to study netty, I would like to know how to send a hello message to all users every 5 seconds, in workerman this is achieved by timers.
1 Answer
In Netty every EventLoop extends ScheduledExecutorService which means you could schedule a task to run every 5 seconds like this:
Channel ch = ...;
ch.eventLoop().scheduleAtFixedRate(() -> {}, 0, 5, TimeUnit.SECONDS);