com.godmao.mqbroker.handler.EventTriggeredHandler Maven / Gradle / Ivy
package com.godmao.mqbroker.handler;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
@ChannelHandler.Sharable
public class EventTriggeredHandler extends ChannelInboundHandlerAdapter {
public static final EventTriggeredHandler INSTANCE = new EventTriggeredHandler();
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
if (evt instanceof IdleStateEvent) {
IdleStateEvent event = (IdleStateEvent) evt;
if (event.state() == IdleState.READER_IDLE) {
ctx.close();
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy