当前位置: 首页>>代码示例>>Java>>正文


Java IdleState.READER_IDLE属性代码示例

本文整理汇总了Java中org.jboss.netty.handler.timeout.IdleState.READER_IDLE属性的典型用法代码示例。如果您正苦于以下问题:Java IdleState.READER_IDLE属性的具体用法?Java IdleState.READER_IDLE怎么用?Java IdleState.READER_IDLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.jboss.netty.handler.timeout.IdleState的用法示例。


在下文中一共展示了IdleState.READER_IDLE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: channelIdle

@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {
    if (!isHandshakeComplete()) {
        return;
    }

    if (e.getState() == IdleState.READER_IDLE) {
        // When no message is received on channel for read timeout, then close
        // the channel
        log.info("Disconnecting client {} due to read timeout", getClientInfoString());
        ctx.getChannel().close();
    } else if (e.getState() == IdleState.WRITER_IDLE) {
        // Send keep alive message
        log.debug("Sending keep alive message due to IdleState timeout " + pc.toString());
        pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build()));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:PcepChannelHandler.java

示例2: channelIdle

@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {
    if (e.getState() == IdleState.WRITER_IDLE) {
        Channel channel = e.getChannel();
        if (channel != null) {
            //写空闲  则发送心跳数据
            channel.write(Heartbeat.getSingleton());
        } else {
            logger.warn("writer idle on channel({}), but hsfChannel is not managed.", e.getChannel());
        }
    } else if (e.getState() == IdleState.READER_IDLE) {
        //读空闲 则断开连接
        logger.error("channel:{} is time out.", e.getChannel());
        handleUpstream(ctx, new DefaultExceptionEvent(e.getChannel(), new SocketTimeoutException(
            "force to close channel(" + ctx.getChannel().getRemoteAddress() + "), reason: time out.")));
        e.getChannel().close();
    }
    super.channelIdle(ctx, e);
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:19,代码来源:StateCheckChannelHandler.java

示例3: channelIdle

private void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) {
    if (e.getState() == IdleState.READER_IDLE) {
        Object a = ctx.getChannel().getAttachment();
        // connect/login timeout
        if (a == null || a instanceof ChannelFuture) {
            ctx.getChannel().close();
            return;
        }
        ChannelData d = (ChannelData)a;
        if (d.timer.elapsed() > TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS)) {
            ctx.getChannel().close();
        } else {
            ctx.sendDownstream(new DownstreamMessageEvent(ctx.getChannel(),
                    new DefaultChannelFuture(ctx.getChannel(), false), PING, null));
        }
    }
}
 
开发者ID:redbooth,项目名称:jssmp,代码行数:17,代码来源:SSMPRequestDecoder.java

示例4: channelIdle

public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) {
    if (e.getState() == IdleState.READER_IDLE) {
        if (_timer.elapsed() > TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS)) {
            ctx.getChannel().close();
        } else {
            L.debug("send ping");
            ctx.sendDownstream(new DownstreamMessageEvent(ctx.getChannel(),
                    new DefaultChannelFuture(ctx.getChannel(), false), PING, null));
        }
    }
}
 
开发者ID:redbooth,项目名称:jssmp,代码行数:11,代码来源:SSMPResponseDecoder.java


注:本文中的org.jboss.netty.handler.timeout.IdleState.READER_IDLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。