MCSM:WebConsole: полученые данных с websocket
This commit is contained in:
@@ -19,14 +19,14 @@ import java.util.concurrent.TimeUnit;
|
||||
public class FrameHandler extends SimpleChannelInboundHandler<WebSocketFrame> {
|
||||
private final Logger logger = LoggerFactory.getLogger(FrameHandler.class);
|
||||
private ScheduledFuture<?> sesFuture;
|
||||
private int i = 1;
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
ctx.channel().writeAndFlush(new TextWebSocketFrame("<S:channelActive>"));
|
||||
|
||||
ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
|
||||
sesFuture = ses.scheduleAtFixedRate(() -> ctx.channel().writeAndFlush(new TextWebSocketFrame("<S:ping>")),
|
||||
1L, 1L, TimeUnit.SECONDS);
|
||||
sesFuture = ses.scheduleAtFixedRate(() -> ctx.channel().writeAndFlush(
|
||||
new TextWebSocketFrame(String.format("<S:ping:%d>", i++))),
|
||||
500L, 1000L, TimeUnit.MILLISECONDS);
|
||||
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user