[FIX] WebSocket ping

This commit is contained in:
Gravit 2019-05-22 23:10:51 +07:00
parent 3c5a83736b
commit e1eaad2cd0

View file

@ -6,6 +6,8 @@
import io.netty.util.CharsetUtil;
import ru.gravit.utils.helper.LogHelper;
import java.util.concurrent.TimeUnit;
public class WebSocketClientHandler extends SimpleChannelInboundHandler<Object> {
private final WebSocketClientHandshaker handshaker;
@ -30,6 +32,9 @@ public void handlerAdded(final ChannelHandlerContext ctx) throws Exception {
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
handshaker.handshake(ctx.channel());
clientJSONPoint.onOpen();
ctx.executor().schedule(() -> {
ctx.channel().writeAndFlush(new PingWebSocketFrame());
}, 20L, TimeUnit.SECONDS);
}
@Override