本文整理匯總了Java中io.netty.channel.Channel.isOpen方法的典型用法代碼示例。如果您正苦於以下問題:Java Channel.isOpen方法的具體用法?Java Channel.isOpen怎麽用?Java Channel.isOpen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.channel.Channel
的用法示例。
在下文中一共展示了Channel.isOpen方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConnectionAndSendRequest
import io.netty.channel.Channel; //導入方法依賴的package包/類
public void getConnectionAndSendRequest(RequestMessage request){
Channel channel = null;
try {
channel = connectionPoll.take();
while(channel != null){
if(channel.isOpen()){
channel.writeAndFlush(request);
return;
}else{
LOGGER.error("連接已經斷開:"+channel.remoteAddress());
channel = connectionPoll.take();
}
}
} catch (Exception e) {
LOGGER.error("getConnectionAndSendRequest happen exception.", e);
}finally{
if(channel != null && channel.isOpen()){
connectionPoll.offer(channel);
}
}
}
示例2: scanNotActiveChannel
import io.netty.channel.Channel; //導入方法依賴的package包/類
/**
* 掃描並關閉失效的Channel
*/
public void scanNotActiveChannel(){
Set<Channel> keySet = chatUserMap.keySet();
for (Channel ch : keySet) {
ChatUser cUser = chatUserMap.get(ch);
if (cUser==null) continue;
if (!ch.isOpen() || !ch.isActive() || (!cUser.isAuth() &&
(System.currentTimeMillis() - cUser.getTime()) > 10000))
removeChannel(ch);
}
}
示例3: scanNotActiveChannel
import io.netty.channel.Channel; //導入方法依賴的package包/類
/**
* 掃描並關閉失效的Channel
*/
public static void scanNotActiveChannel() {
Set<Channel> keySet = userInfos.keySet();
for (Channel ch : keySet) {
UserInfo userInfo = userInfos.get(ch);
if (userInfo == null) continue;
if (!ch.isOpen() || !ch.isActive() || (!userInfo.isAuth() &&
(System.currentTimeMillis() - userInfo.getTime()) > 10000)) {
removeChannel(ch);
}
}
}
示例4: validateObject
import io.netty.channel.Channel; //導入方法依賴的package包/類
@Override
public boolean validateObject(Channel channel) {
return channel.isOpen();
}
示例5: isOpen
import io.netty.channel.Channel; //導入方法依賴的package包/類
@Override
protected boolean isOpen(Channel channel) {
return channel.isOpen();
}