简体   繁体   中英

How to do the operation every 5 seconds netty (Server)

我以前在workerman php工作,创建一个websocket服务器,但由于我经常在java上工作,我决定研究netty,我想知道如何每隔5秒向所有用户发送一个hello消息,在workerman这是通过计时器。

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM