當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。