Archived
0

MCSM:WebConsole: полученые данных с websocket

This commit is contained in:
2017-05-11 01:19:12 +03:00
parent 16cdc30d3c
commit 338d7d656b
3 changed files with 31 additions and 18 deletions

View File

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