Add getSessionsForAddress to return all the active sessions for a given IP address.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5682 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -21,11 +21,13 @@
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -179,6 +181,23 @@ public class ClientManager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all sessions logged in from the given IP in the form returned from
|
||||
* {@link InetAddress#getAddress()}.
|
||||
*/
|
||||
public List<PresentsSession> getSessionsForAddress (byte[] addr)
|
||||
{
|
||||
List<PresentsSession> sessions = Lists.newArrayListWithExpectedSize(1);
|
||||
synchronized (_usermap) {
|
||||
for (PresentsSession session : _usermap.values()) {
|
||||
if (Arrays.equals(addr, session.getInetAddress().getAddress())) {
|
||||
sessions.add(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of connected clients.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user