Track a user's connection status in their occupant info so that we can

react to player disconnection, idle (implementation still pending), and
reconnection appropriately.  Added PlaceManager.bodyUpdated().


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1831 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2002-10-26 02:40:30 +00:00
parent ad344e05e1
commit fec48b8586
5 changed files with 118 additions and 15 deletions
@@ -1,16 +1,63 @@
//
// $Id: CrowdClient.java,v 1.10 2002/09/19 23:36:59 mdb Exp $
// $Id: CrowdClient.java,v 1.11 2002/10/26 02:40:30 shaper Exp $
package com.threerings.crowd.server;
import com.threerings.presents.server.PresentsClient;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer;
/**
* The crowd client extends the presents client but doesn't really do
* anything at present. It exists mainly so that implementation systems
* will extend it and ensure that we have the option of adding
* functionality here in the future.
* The crowd client extends the presents client with crowd-specific client
* handling.
*/
public class CrowdClient extends PresentsClient
{
// documentation inherited
protected void wasUnmapped ()
{
super.wasUnmapped();
if (_clobj != null) {
BodyObject bobj = (BodyObject)_clobj;
// get the location the user is occupying
PlaceObject plobj = (PlaceObject)
CrowdServer.omgr.getObject(bobj.location);
if (plobj != null) {
// update their occupant info with their new connection
// status
OccupantInfo info = (OccupantInfo)plobj.occupantInfo.get(
new Integer(bobj.getOid()));
if (info != null) {
info.status = OccupantInfo.DISCONNECTED;
plobj.updateOccupantInfo(info);
}
}
}
}
// documentation inherited
protected void sessionWillResume ()
{
super.sessionWillResume();
BodyObject bobj = (BodyObject)_clobj;
// get the location the user is occupying
PlaceObject plobj = (PlaceObject)
CrowdServer.omgr.getObject(bobj.location);
if (plobj != null) {
// update their occupant info with their new connection status
OccupantInfo info = (OccupantInfo)plobj.occupantInfo.get(
new Integer(bobj.getOid()));
if (info != null) {
info.status = OccupantInfo.ACTIVE;
plobj.updateOccupantInfo(info);
}
}
}
}
@@ -1,5 +1,5 @@
//
// $Id: PlaceManager.java,v 1.38 2002/10/06 03:31:16 mdb Exp $
// $Id: PlaceManager.java,v 1.39 2002/10/26 02:40:30 shaper Exp $
package com.threerings.crowd.server;
@@ -14,6 +14,9 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.EntryAddedEvent;
import com.threerings.presents.dobj.EntryRemovedEvent;
import com.threerings.presents.dobj.EntryUpdatedEvent;
import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.dobj.MessageListener;
import com.threerings.presents.dobj.ObjectAddedEvent;
@@ -21,6 +24,7 @@ import com.threerings.presents.dobj.ObjectDeathListener;
import com.threerings.presents.dobj.ObjectDestroyedEvent;
import com.threerings.presents.dobj.ObjectRemovedEvent;
import com.threerings.presents.dobj.OidListListener;
import com.threerings.presents.dobj.SetListener;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject;
@@ -53,7 +57,7 @@ import com.threerings.crowd.chat.SpeakProvider;
*/
public class PlaceManager
implements MessageListener, OidListListener, ObjectDeathListener,
SpeakProvider.SpeakerValidator
SetListener, SpeakProvider.SpeakerValidator
{
/**
* An interface used to allow the registration of standard message
@@ -381,6 +385,19 @@ public class PlaceManager
}
}
/**
* Called when a body's occupant info is updated.
*/
protected void bodyUpdated (final OccupantInfo info)
{
// let our delegates know what's up
applyToDelegates(new DelegateOp() {
public void apply (PlaceManagerDelegate delegate) {
delegate.bodyUpdated(info);
}
});
}
/**
* Called when we transition from having bodies in the place to not
* having any bodies in the place. Some places may take this as a sign
@@ -471,6 +488,24 @@ public class PlaceManager
didShutdown();
}
// documentation inherited from interface
public void entryAdded (EntryAddedEvent event)
{
}
// documentation inherited from interface
public void entryUpdated (EntryUpdatedEvent event)
{
if (event.getName().equals(PlaceObject.OCCUPANT_INFO)) {
bodyUpdated((OccupantInfo)event.getEntry());
}
}
// documentation inherited from interface
public void entryRemoved (EntryRemovedEvent event)
{
}
// documentation inherited from interface
public boolean isValidSpeaker (DObject speakObj, ClientObject speaker)
{
@@ -1,8 +1,9 @@
//
// $Id: PlaceManagerDelegate.java,v 1.1 2002/02/13 03:21:28 mdb Exp $
// $Id: PlaceManagerDelegate.java,v 1.2 2002/10/26 02:40:30 shaper Exp $
package com.threerings.crowd.server;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
@@ -64,6 +65,13 @@ public class PlaceManagerDelegate
{
}
/**
* Called when a body occupant info is updated.
*/
public void bodyUpdated (OccupantInfo info)
{
}
/**
* Called when the last body leaves the place.
*/