Various updates to allow a system where a user's visible name is not the same
as their authentication name (which we leave in BodyObject.username). This turns out to be simpler than the system we adopted for Yohoho wherein we replace the player's user object after they select a character, but converting to this sort of system is way more work than would be worth it. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3758 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -92,7 +92,7 @@ public class CrowdClient extends PresentsClient
|
||||
|
||||
// clear our chat history
|
||||
if (body != null) {
|
||||
SpeakProvider.clearHistory(body.username);
|
||||
SpeakProvider.clearHistory(body.getVisibleName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ public class CrowdServer extends PresentsServer
|
||||
// configure the dobject manager with our access controller
|
||||
omgr.setDefaultAccessController(CrowdObjectAccess.DEFAULT);
|
||||
|
||||
// create our body locator
|
||||
_lookup = createBodyLocator();
|
||||
|
||||
// create our place registry
|
||||
plreg = createPlaceRegistry(invmgr, omgr);
|
||||
|
||||
@@ -81,6 +84,21 @@ public class CrowdServer extends PresentsServer
|
||||
return new PlaceRegistry(invmgr, omgr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow derived instances to create a custom {@link BodyLocator}. If the
|
||||
* system opts not to use {@link BodyObject#username} as a user's visible
|
||||
* name, it will need to provide a custom {@link BodyLocator}.
|
||||
*/
|
||||
protected BodyLocator createBodyLocator ()
|
||||
{
|
||||
return new BodyLocator() {
|
||||
public BodyObject get (Name visibleName) {
|
||||
// by default visibleName is username
|
||||
return (BodyObject)clmgr.getClientObject(visibleName);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates the body objects for all active users on the server.
|
||||
* This should only be called from the dobjmgr thread. The caller had
|
||||
@@ -93,13 +111,13 @@ public class CrowdServer extends PresentsServer
|
||||
}
|
||||
|
||||
/**
|
||||
* The server maintains a mapping of username to body object for all
|
||||
* active users on the server. This should only be called from the
|
||||
* dobjmgr thread.
|
||||
* Looks up the {@link BodyObject} for the user with the specified visible
|
||||
* name, returns null if they are not online. This should only be called
|
||||
* from the dobjmgr thread.
|
||||
*/
|
||||
public static BodyObject lookupBody (Name username)
|
||||
public static BodyObject lookupBody (Name visibleName)
|
||||
{
|
||||
return (BodyObject)clmgr.getClientObject(username);
|
||||
return _lookup.get(visibleName);
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
@@ -114,6 +132,20 @@ public class CrowdServer extends PresentsServer
|
||||
}
|
||||
}
|
||||
|
||||
/** An interface that allows server extensions to reconfigure the body
|
||||
* lookup process. See {@link #lookupBody}, {@link #createBodyLocator}. */
|
||||
protected static interface BodyLocator
|
||||
{
|
||||
/** Returns the body object for the user with the specified visible
|
||||
* name, or null if they are not online. This will only be called from
|
||||
* the dobjmgr thread. */
|
||||
public BodyObject get (Name visibleName);
|
||||
}
|
||||
|
||||
/** Used to look up {@link BodyObject} instance for online users. See
|
||||
* {@link #lookupBody}. */
|
||||
protected static BodyLocator _lookup;
|
||||
|
||||
/** The config key for our list of invocation provider mappings. */
|
||||
protected final static String PROVIDERS_KEY = "providers";
|
||||
}
|
||||
|
||||
@@ -408,9 +408,9 @@ public class PlaceManager
|
||||
*/
|
||||
protected void populateOccupantInfo (OccupantInfo info, BodyObject body)
|
||||
{
|
||||
// the base occupant info is only their username
|
||||
// the base occupant info is only their name and connection status
|
||||
info.bodyOid = new Integer(body.getOid());
|
||||
info.username = body.username;
|
||||
info.username = body.getVisibleName();
|
||||
info.status = body.status;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user