Java Code Examples for org.apache.mina.common.IoSession#isConnected()

The following examples show how to use org.apache.mina.common.IoSession#isConnected() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MinaChannel.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
static MinaChannel getOrAddChannel(IoSession session, URL url, ChannelHandler handler) {
    if (session == null) {
        return null;
    }
    MinaChannel ret = (MinaChannel) session.getAttribute(CHANNEL_KEY);
    if (ret == null) {
        ret = new MinaChannel(session, url, handler);
        if (session.isConnected()) {
            MinaChannel old = (MinaChannel) session.setAttribute(CHANNEL_KEY, ret);
            if (old != null) {
                session.setAttribute(CHANNEL_KEY, old);
                ret = old;
            }
        }
    }
    return ret;
}
 
Example 2
Source File: MinaChannel.java    From dubbox with Apache License 2.0 6 votes vote down vote up
static MinaChannel getOrAddChannel(IoSession session, URL url, ChannelHandler handler) {
    if (session == null) {
        return null;
    }
    MinaChannel ret = (MinaChannel) session.getAttribute(CHANNEL_KEY);
    if (ret == null) {
        ret = new MinaChannel(session, url, handler);
        if (session.isConnected()) {
            MinaChannel old = (MinaChannel) session.setAttribute(CHANNEL_KEY, ret);
            if (old != null) {
                session.setAttribute(CHANNEL_KEY, old);
                ret = old;
            }
        }
    }
    return ret;
}
 
Example 3
Source File: MinaChannel.java    From dubbox with Apache License 2.0 6 votes vote down vote up
static MinaChannel getOrAddChannel(IoSession session, URL url, ChannelHandler handler) {
    if (session == null) {
        return null;
    }
    MinaChannel ret = (MinaChannel) session.getAttribute(CHANNEL_KEY);
    if (ret == null) {
        ret = new MinaChannel(session, url, handler);
        if (session.isConnected()) {
            MinaChannel old = (MinaChannel) session.setAttribute(CHANNEL_KEY, ret);
            if (old != null) {
                session.setAttribute(CHANNEL_KEY, old);
                ret = old;
            }
        }
    }
    return ret;
}
 
Example 4
Source File: MinaChannel.java    From dubbox with Apache License 2.0 6 votes vote down vote up
static MinaChannel getOrAddChannel(IoSession session, URL url, ChannelHandler handler) {
    if (session == null) {
        return null;
    }
    MinaChannel ret = (MinaChannel) session.getAttribute(CHANNEL_KEY);
    if (ret == null) {
        ret = new MinaChannel(session, url, handler);
        if (session.isConnected()) {
            MinaChannel old = (MinaChannel) session.setAttribute(CHANNEL_KEY, ret);
            if (old != null) {
                session.setAttribute(CHANNEL_KEY, old);
                ret = old;
            }
        }
    }
    return ret;
}
 
Example 5
Source File: MinaChannel.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
static MinaChannel getOrAddChannel(IoSession session, URL url, ChannelHandler handler) {
    if (session == null) {
        return null;
    }
    MinaChannel ret = (MinaChannel) session.getAttribute(CHANNEL_KEY);
    if (ret == null) {
        ret = new MinaChannel(session, url, handler);
        if (session.isConnected()) {
            MinaChannel old = (MinaChannel) session.setAttribute(CHANNEL_KEY, ret);
            if (old != null) {
                session.setAttribute(CHANNEL_KEY, old);
                ret = old;
            }
        }
    }
    return ret;
}
 
Example 6
Source File: MinaClient.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Channel getChannel() {
    IoSession s = session;
    if (s == null || ! s.isConnected())
        return null;
    return MinaChannel.getOrAddChannel(s, getUrl(), this);
}
 
Example 7
Source File: MinaServer.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<Channel> getChannels() {
    Set<IoSession> sessions = acceptor.getManagedSessions(getBindAddress());
    Collection<Channel> channels = new HashSet<Channel>();
    for (IoSession session : sessions) {
        if (session.isConnected()) {
            channels.add(MinaChannel.getOrAddChannel(session, getUrl(), this));
        }
    }
    return channels;
}
 
Example 8
Source File: MinaServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Collection<Channel> getChannels() {
    Set<IoSession> sessions = acceptor.getManagedSessions(getBindAddress());
    Collection<Channel> channels = new HashSet<Channel>();
    for (IoSession session : sessions) {
        if (session.isConnected()) {
            channels.add(MinaChannel.getOrAddChannel(session, getUrl(), this));
        }
    }
    return channels;
}
 
Example 9
Source File: MinaClient.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Channel getChannel() {
    IoSession s = session;
    if (s == null || ! s.isConnected())
        return null;
    return MinaChannel.getOrAddChannel(s, getUrl(), this);
}
 
Example 10
Source File: MinaServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Collection<Channel> getChannels() {
    Set<IoSession> sessions = acceptor.getManagedSessions(getBindAddress());
    Collection<Channel> channels = new HashSet<Channel>();
    for (IoSession session : sessions) {
        if (session.isConnected()) {
            channels.add(MinaChannel.getOrAddChannel(session, getUrl(), this));
        }
    }
    return channels;
}
 
Example 11
Source File: MinaClient.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Override
protected Channel getChannel() {
    IoSession s = session;
    if (s == null || ! s.isConnected())
        return null;
    return MinaChannel.getOrAddChannel(s, getUrl(), this);
}
 
Example 12
Source File: MinaServer.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public Collection<Channel> getChannels() {
    Set<IoSession> sessions = acceptor.getManagedSessions(getBindAddress());
    Collection<Channel> channels = new HashSet<Channel>();
    for (IoSession session : sessions) {
        if (session.isConnected()) {
            channels.add(MinaChannel.getOrAddChannel(session, getUrl(), this));
        }
    }
    return channels;
}
 
Example 13
Source File: MinaClient.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
protected Channel getChannel() {
    IoSession s = session;
    if (s == null || ! s.isConnected())
        return null;
    return MinaChannel.getOrAddChannel(s, getUrl(), this);
}
 
Example 14
Source File: MinaServer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Collection<Channel> getChannels() {
    Set<IoSession> sessions = acceptor.getManagedSessions(getBindAddress());
    Collection<Channel> channels = new HashSet<Channel>();
    for (IoSession session : sessions) {
        if (session.isConnected()) {
            channels.add(MinaChannel.getOrAddChannel(session, getUrl(), this));
        }
    }
    return channels;
}
 
Example 15
Source File: MinaClient.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
protected Channel getChannel() {
    IoSession s = session;
    if (s == null || !s.isConnected())
        return null;
    return MinaChannel.getOrAddChannel(s, getUrl(), this);
}
 
Example 16
Source File: MinaChannel.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnectd(IoSession session) {
    if (session != null && ! session.isConnected()) {
        session.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 17
Source File: MinaChannel.java    From dubbox with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnectd(IoSession session) {
    if (session != null && ! session.isConnected()) {
        session.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 18
Source File: MinaChannel.java    From dubbox with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnectd(IoSession session) {
    if (session != null && ! session.isConnected()) {
        session.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 19
Source File: MinaChannel.java    From dubbox with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnectd(IoSession session) {
    if (session != null && ! session.isConnected()) {
        session.removeAttribute(CHANNEL_KEY);
    }
}
 
Example 20
Source File: MinaChannel.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
static void removeChannelIfDisconnected(IoSession session) {
    if (session != null && !session.isConnected()) {
        session.removeAttribute(CHANNEL_KEY);
    }
}