Initial revision of occupant management services.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@276 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-08-20 20:54:57 +00:00
parent 6756d332f8
commit 04b5bfba8c
5 changed files with 236 additions and 12 deletions
@@ -1,5 +1,5 @@
//
// $Id: LocationProvider.java,v 1.6 2001/08/16 04:28:36 mdb Exp $
// $Id: LocationProvider.java,v 1.7 2001/08/20 20:54:57 mdb Exp $
package com.threerings.cocktail.party.server;
@@ -42,6 +42,8 @@ public class LocationProvider extends InvocationProvider
*/
public static String moveTo (BodyObject source, int placeId)
{
int bodoid = source.getOid();
// make sure the place in question actually exists
PlaceManager pmgr = PartyServer.plreg.getPlaceManager(placeId);
if (pmgr == null) {
@@ -71,21 +73,22 @@ public class LocationProvider extends InvocationProvider
PlaceObject pold = (PlaceObject)
PartyServer.omgr.getObject(source.location);
if (pold != null) {
pold.removeFromOccupants(source.getOid());
// also remove their occupant info (which is keyed on
// username)
pold.removeFromOccupantInfo(source.username);
Object key = new Integer(bodoid);
// remove their occupant info (which is keyed on oid)
pold.removeFromOccupantInfo(key);
// and remove them from the occupant list
pold.removeFromOccupants(bodoid);
} else {
Log.info("Body's prior location no longer around? " +
"[boid=" + source.getOid() +
"[boid=" + bodoid +
", poid=" + source.location + "].");
}
} catch (ClassCastException cce) {
Log.warning("Body claims to be at location which " +
"references non-PlaceObject!? " +
"[boid=" + source.getOid() +
"[boid=" + bodoid +
", poid=" + source.location + "].");
}
}
@@ -102,7 +105,7 @@ public class LocationProvider extends InvocationProvider
}
// add the body object id to the place object's occupant list
place.addToOccupants(source.getOid());
place.addToOccupants(bodoid);
// and finally queue up a lock release event to release the lock
// once all these events are processed
@@ -1,5 +1,5 @@
//
// $Id: PlaceManager.java,v 1.8 2001/08/16 04:28:36 mdb Exp $
// $Id: PlaceManager.java,v 1.9 2001/08/20 20:54:57 mdb Exp $
package com.threerings.cocktail.party.server;
@@ -126,6 +126,7 @@ public class PlaceManager implements Subscriber
protected void populateOccupantInfo (OccupantInfo info, BodyObject body)
{
// the base occupant info is only their username
info.bodyOid = new Integer(body.getOid());
info.username = body.username;
}
@@ -145,6 +146,14 @@ public class PlaceManager implements Subscriber
{
Log.info("Body left [ploid=" + _plobj.getOid() +
", oid=" + bodyOid + "].");
// if their occupant info hasn't been removed (which may be the
// case if they logged off rather than left via a MoveTo request),
// we need to get it on out of here
Object key = new Integer(bodyOid);
if (_plobj.occupantInfo.containsKey(key)) {
_plobj.removeFromOccupantInfo(key);
}
}
/**