本文整理汇总了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();
}