net.fs.rudp.CopiedIterator Java Examples

The following examples show how to use net.fs.rudp.CopiedIterator. 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: TunManager.java    From finalspeed with GNU General Public License v2.0 6 votes vote down vote up
void scan() {
    CopiedIterator<String> it = getConnTableIterator();
    while (it.hasNext()) {
        String key = it.next();
        TCPTun tun = connTable.get(key);
        if (tun != null) {
            if (tun.preDataReady) {
                //无数据超时
                long t = System.currentTimeMillis() - tun.lastReceiveDataTime;
                if (t > 6000) {
                    connTable.remove(key);
                    if (capEnv.client) {
                        defaultTcpTun = null;
                        MLog.println("tcp隧道超时");
                    }
                }
            } else {
                //连接中超时
                if (System.currentTimeMillis() - tun.createTime > 5000) {
                    connTable.remove(key);
                }
            }
        }
    }
}
 
Example #2
Source File: TunManager.java    From finalspeed with GNU General Public License v2.0 5 votes vote down vote up
CopiedIterator<String> getConnTableIterator() {
    CopiedIterator<String> it;
    synchronized (syn_scan) {
        it = new CopiedIterator<>(connTable.keySet().iterator());
    }
    return it;
}