Search in sources :

Example 1 with HeartBeat

use of pers.cy.iris.commons.network.protocol.request.HeartBeat in project iris by chicc999.

the class DefaultConnectionHandler method userEventTriggered.

@Override
public void userEventTriggered(final ChannelHandlerContext ctx, final Object evt) throws Exception {
    if (evt instanceof IdleStateEvent) {
        IdleStateEvent event = (IdleStateEvent) evt;
        if (event.state().equals(IdleState.ALL_IDLE)) {
            logger.debug("channel {} is idle.", ctx.channel());
            ctx.writeAndFlush(new HeartBeat()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
        }
    }
    super.userEventTriggered(ctx, evt);
}
Also used : IdleStateEvent(io.netty.handler.timeout.IdleStateEvent) HeartBeat(pers.cy.iris.commons.network.protocol.request.HeartBeat)

Aggregations

IdleStateEvent (io.netty.handler.timeout.IdleStateEvent)1 HeartBeat (pers.cy.iris.commons.network.protocol.request.HeartBeat)1