fix: 兼容 1.12.2 服务端
This commit is contained in:
@@ -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<IdleStateEvent> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user