From c21d63de5f37e4f3dac06c85ce6a2e87e530bad8 Mon Sep 17 00:00:00 2001 From: MiniDay <372403923@qq.com> Date: Mon, 31 Oct 2022 12:27:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=201.12.2=20=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/connector/BallKeepAliveHandler.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hamster-ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/connector/BallKeepAliveHandler.java b/hamster-ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/connector/BallKeepAliveHandler.java index cfbcc6e..3e868a0 100644 --- a/hamster-ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/connector/BallKeepAliveHandler.java +++ b/hamster-ball-common/src/main/java/cn/hamster3/mc/plugin/ball/common/connector/BallKeepAliveHandler.java @@ -2,19 +2,23 @@ package cn.hamster3.mc.plugin.ball.common.connector; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleUserEventChannelHandler; +import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.handler.timeout.IdleStateEvent; @ChannelHandler.Sharable -public class BallKeepAliveHandler extends SimpleUserEventChannelHandler { +public class BallKeepAliveHandler extends ChannelInboundHandlerAdapter { public static final BallKeepAliveHandler INSTANCE = new BallKeepAliveHandler(); private BallKeepAliveHandler() { - super(true); + super(); } @Override - protected void eventReceived(ChannelHandlerContext context, IdleStateEvent event) { - context.channel().writeAndFlush("ping"); + public void userEventTriggered(ChannelHandlerContext context, Object event) throws Exception { + if (event instanceof IdleStateEvent) { + context.channel().writeAndFlush("ping"); + return; + } + super.userEventTriggered(context, event); } }