Java Code Examples for io.netty.channel.Channel.isOpen()

The following are Jave code examples for showing how to use isOpen() of the io.netty.channel.Channel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: lionrpc   File: LionConnectionManager.java   Source Code and License Vote up 6 votes
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);
		}
	}
}
 
Example 2
Project: JavaQuarkBBS   File: ChannelManager.java   Source Code and License Vote up 5 votes
/**
 * 扫描并关闭失效的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);
    }
}
 
Example 3
Project: HappyChat   File: UserInfoManager.java   Source Code and License Vote up 5 votes
/**
 * 扫描并关闭失效的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);
        }
    }
}
 
Example 4
Project: angel   File: ChannelObjectFactory.java   Source Code and License Vote up 4 votes
@Override
public boolean validateObject(Channel channel) {
  return channel.isOpen();
}
 
Example 5
Project: elasticsearch_my   File: Netty4Transport.java   Source Code and License Vote up 4 votes
@Override
protected boolean isOpen(Channel channel) {
    return channel.isOpen();
}