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


Java Channel.hasAttr方法代码示例

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


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

示例1: call

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
public void call(ChannelHandlerContext context, PushResp message) {
    Channel channel = context.channel();
    if (!channel.hasAttr(Constants.CHANNEL_ATTR_HANDSHAKE)) {
        log.warn("channel not handshake, channel:{}", channel);
        context.close();
        return;
    }
    //接收成功后,将推送的消息置换成已读或删除等操作
    if (PushResp.Result.S.equals(message.getResult()) || PushResp.Result.D.equals(message.getResult())) {
        putMsg(message);
        log.info("receive pushResp, device:{}, msg_id:{}, result:{}!", message.getDevice(), message.getMsgId(), message.getResult());
    } else {
        log.warn("receive pushResp, device:{}, msg_id:{}, result:{}", message.getDevice(), message.getMsgId(), message.getResult());
    }

}
 
开发者ID:lee123lee123,项目名称:GoPush,代码行数:18,代码来源:PushRespHandler.java

示例2: clearUnheart

import io.netty.channel.Channel; //导入方法依赖的package包/类
private void clearUnheart() {
	if (checkHeartWhenConnectionCount > connectionCount.get()) {
		return;
	}
	long now = System.currentTimeMillis();
	for (Channel channel : validatedChannels) {
		long last = 0;
		long first = 0;
		int count = 0;
		if (channel.hasAttr(LAST_HEART_TIME)) {
			last = channel.attr(LAST_HEART_TIME).get();
		}
		if (channel.hasAttr(FIRST_HEART_TIME)) {
			first = channel.attr(FIRST_HEART_TIME).get();
		}
		if (channel.hasAttr(HEART_COUNT)) {
			count = channel.attr(HEART_COUNT).get();
		}
		int allow = (int) ((now - first) / (heartIntervalSec * 1000));
		if (count - 2 > allow) {
			log.error(channel + " heart too quick,might be Game Accelerator,please check!");
			channel.pipeline().fireExceptionCaught(new HeartTooQuickException(channel, first, now, count, allow));
			channel.attr(FIRST_HEART_TIME).set(now);
			channel.attr(HEART_COUNT).set(0);
		}
		if (count < allow - 2) {
			channel.pipeline().fireExceptionCaught(new HeartNotAnswerException(channel, first, last, count));
			channel.close();
		}
	}
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:32,代码来源:BinaryServer.java

示例3: isDcChannelToSave

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
public void isDcChannelToSave(Channel channel) {
    if (!channel.hasAttr(Constants.CHANNEL_ATTR_DATACENTER)) {
        //添加相应的值
        String dcId = dataCenterId(channel);
        channel.attr(Constants.CHANNEL_ATTR_DATACENTER).set(dcId);
        if (!contains(dcId)) {
            addChannel(dcId, channel);
        }
    }
}
 
开发者ID:lee123lee123,项目名称:GoPush,代码行数:12,代码来源:DataCenterChannelStore.java

示例4: isDcChannelToRemove

import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
public void isDcChannelToRemove(Channel channel) {
    String dcId = null;
    if (!channel.hasAttr(Constants.CHANNEL_ATTR_DATACENTER)) {
        dcId = dataCenterId(channel);
    } else {
        dcId = channel.attr(Constants.CHANNEL_ATTR_DATACENTER).get();
    }
    if (contains(dcId)) {
        removeChannel(dcId, channel);
    }
}
 
开发者ID:lee123lee123,项目名称:GoPush,代码行数:13,代码来源:DataCenterChannelStore.java

示例5: checkHandShake

import io.netty.channel.Channel; //导入方法依赖的package包/类
/**
 * 检测是否已经握手
 *
 * @param channel
 * @return
 */
protected boolean checkHandShake(Channel channel) {
    if (!channel.hasAttr(Constants.CHANNEL_ATTR_HANDSHAKE)) {
        log.warn("channel not handshake, channel:{}", channel);
        return Boolean.FALSE;
    }
    return Boolean.TRUE;
}
 
开发者ID:lee123lee123,项目名称:GoPush,代码行数:14,代码来源:PingPongProcessor.java

示例6: checkAuth

import io.netty.channel.Channel; //导入方法依赖的package包/类
protected void checkAuth(Channel ch) throws NotAuthException {
    if (!ch.hasAttr(Constants.KEY_USER_ID)) {
        throw new NotAuthException();
    }
}
 
开发者ID:onsoul,项目名称:os,代码行数:6,代码来源:AbstractOperation.java


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