From 4fc5f574d8f9f240dfaeff1945421ad23d1bffd4 Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Thu, 18 Apr 2002 00:44:50 +0000 Subject: [PATCH] Added facility for enumerating the body objects for all active users on the server. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1274 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/crowd/server/CrowdServer.java | 18 +++++++++++++----- .../presents/server/ClientManager.java | 11 ++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/java/com/threerings/crowd/server/CrowdServer.java b/src/java/com/threerings/crowd/server/CrowdServer.java index 9f9382781..66b21bd6b 100644 --- a/src/java/com/threerings/crowd/server/CrowdServer.java +++ b/src/java/com/threerings/crowd/server/CrowdServer.java @@ -1,9 +1,9 @@ // -// $Id: CrowdServer.java,v 1.11 2002/03/28 22:32:31 mdb Exp $ +// $Id: CrowdServer.java,v 1.12 2002/04/18 00:44:50 shaper Exp $ package com.threerings.crowd.server; -import java.util.HashMap; +import java.util.Iterator; import com.threerings.presents.server.PresentsServer; @@ -48,6 +48,17 @@ public class CrowdServer extends PresentsServer Log.info("Crowd server initialized."); } + /** + * Enumerates the body objects for all active users on the server. + * This should only be called from the dobjmgr thread. The caller had + * best be certain they know what they're doing, since this should + * only be necessary for use in rather special circumstances. + */ + public static Iterator enumerateBodies () + { + return clmgr.enumerateClientObjects(); + } + /** * The server maintains a mapping of username to body object for all * active users on the server. This should only be called from the @@ -70,9 +81,6 @@ public class CrowdServer extends PresentsServer } } - /** We use this to map usernames to body objects. */ - protected static HashMap _bodymap = new HashMap(); - /** The config key for our list of invocation provider mappings. */ protected final static String PROVIDERS_KEY = "providers"; } diff --git a/src/java/com/threerings/presents/server/ClientManager.java b/src/java/com/threerings/presents/server/ClientManager.java index 007b4211f..334a2970f 100644 --- a/src/java/com/threerings/presents/server/ClientManager.java +++ b/src/java/com/threerings/presents/server/ClientManager.java @@ -1,10 +1,11 @@ // -// $Id: ClientManager.java,v 1.14 2002/03/05 05:33:25 mdb Exp $ +// $Id: ClientManager.java,v 1.15 2002/04/18 00:44:50 shaper Exp $ package com.threerings.presents.server; import java.io.IOException; import java.util.HashMap; +import java.util.Iterator; import com.threerings.presents.Log; import com.threerings.presents.data.ClientObject; @@ -74,6 +75,14 @@ public class ClientManager implements ConnectionObserver } } + /** + * Enumerates all active client objects. + */ + public Iterator enumerateClientObjects () + { + return _objmap.values().iterator(); + } + /** * Returns the client object associated with the specified username. * This will return null unless the client object is resolved for some