Added support for initiating a place/scene/zone transition from the

server; chat director no longer needs to wait until we're logged on to
register itself with the invocation director.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1393 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-05-26 02:24:46 +00:00
parent 8a7a046df8
commit 97197d49cc
10 changed files with 251 additions and 73 deletions
@@ -1,5 +1,5 @@
//
// $Id: SceneDirector.java,v 1.13 2002/05/22 21:48:44 shaper Exp $
// $Id: SceneDirector.java,v 1.14 2002/05/26 02:24:46 mdb Exp $
package com.threerings.whirled.client;
@@ -234,6 +234,36 @@ public class SceneDirector
_locdir.failedToMoveTo(sceneId, reason);
}
/**
* Called to clean up our place and scene state information when we
* leave a scene.
*/
public void didLeaveScene ()
{
// let the location director know what's up
_locdir.didLeavePlace();
// clear out our own scene state
clearScene();
}
/**
* Called when the server has decided to forcibly move us to another
* scene. The server first ejects us from our previous scene and then
* sends us a notification with our new location. We then turn around
* and issue a standard moveTo request.
*/
public void handleMoveNotification (int sceneId)
{
Log.info("Moving at request of server [sceneId=" + sceneId + "].");
// clear out our old scene and place data
didLeaveScene();
// move to the new scene
moveTo(sceneId);
}
/**
* Called when something breaks down in the process of performing a
* <code>moveTo</code> request.
@@ -1,8 +1,9 @@
//
// $Id: SceneProvider.java,v 1.8 2002/04/15 16:28:03 shaper Exp $
// $Id: SceneProvider.java,v 1.9 2002/05/26 02:24:46 mdb Exp $
package com.threerings.whirled.server;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.presents.server.ServiceFailedException;
@@ -26,8 +27,9 @@ public class SceneProvider extends InvocationProvider
* Constructs a scene provider that will interact with the supplied
* scene registry.
*/
public SceneProvider (SceneRegistry screg)
public SceneProvider (InvocationManager invmgr, SceneRegistry screg)
{
_invmgr = invmgr;
_screg = screg;
}
@@ -101,6 +103,25 @@ public class SceneProvider extends InvocationProvider
}
}
/**
* Ejects the specified body from their current scene and sends them a
* request to move to the specified new scene. This is the
* scene-equivalent to {@link LocationProvider#moveBody}.
*/
public void moveBody (BodyObject source, int sceneId)
{
// first remove them from their old place
LocationProvider.leaveOccupiedPlace(source);
// then send a move notification
_invmgr.sendNotification(
source.getOid(), MODULE_NAME, MOVE_NOTIFICATION,
new Object[] { new Integer(sceneId) });
}
/** The invocation manager with which we interact. */
protected InvocationManager _invmgr;
/** The scene registry with which we interact. */
protected SceneRegistry _screg;
}
@@ -1,5 +1,5 @@
//
// $Id: SceneRegistry.java,v 1.14 2002/05/24 05:58:55 mdb Exp $
// $Id: SceneRegistry.java,v 1.15 2002/05/26 02:24:46 mdb Exp $
package com.threerings.whirled.server;
@@ -50,7 +50,7 @@ public class SceneRegistry
_scfact = new DefaultRuntimeSceneFactory();
// create/register a scene provider with the invocation services
SceneProvider provider = new SceneProvider(this);
SceneProvider provider = new SceneProvider(invmgr, this);
invmgr.registerProvider(SceneProvider.MODULE_NAME, provider);
}
@@ -1,5 +1,5 @@
//
// $Id: ZoneDirector.java,v 1.4 2001/12/17 04:11:40 mdb Exp $
// $Id: ZoneDirector.java,v 1.5 2002/05/26 02:24:46 mdb Exp $
package com.threerings.whirled.zone.client;
@@ -149,6 +149,24 @@ public class ZoneDirector
notifyObservers(reason);
}
/**
* Called when the server has decided to forcibly move us to another
* zone and scene. The server first ejects us from our previous scene
* and then sends us a notification with our new location. We then
* turn around and issue a standard moveTo request.
*/
public void handleMoveNotification (int zoneId, int sceneId)
{
Log.info("Moving at request of server [zoneId=" + zoneId +
", sceneId=" + sceneId + "].");
// clear out our old scene and place data
_scdir.didLeaveScene();
// move to the new zone and scene
moveTo(zoneId, sceneId);
}
/**
* Notifies observers of success or failure, depending on the type of
* object provided as data.
@@ -1,8 +1,9 @@
//
// $Id: ZoneProvider.java,v 1.7 2002/05/03 00:00:17 mdb Exp $
// $Id: ZoneProvider.java,v 1.8 2002/05/26 02:24:46 mdb Exp $
package com.threerings.whirled.zone.server;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.presents.server.ServiceFailedException;
@@ -33,8 +34,10 @@ public class ZoneProvider
* constructed and registered by the {@link ZoneRegistry}, which a
* zone-using system must create and initialize in their server.
*/
public ZoneProvider (ZoneRegistry zonereg, SceneRegistry screg)
public ZoneProvider (
InvocationManager invmgr, ZoneRegistry zonereg, SceneRegistry screg)
{
_invmgr = invmgr;
_zonereg = zonereg;
_screg = screg;
}
@@ -174,6 +177,25 @@ public class ZoneProvider
}
}
/**
* Ejects the specified body from their current scene and sends them a
* request to move to the specified new zone and scene. This is the
* zone-equivalent to {@link LocationProvider#moveBody}.
*/
public void moveBody (BodyObject source, int zoneId, int sceneId)
{
// first remove them from their old place
LocationProvider.leaveOccupiedPlace(source);
// then send a move notification
_invmgr.sendNotification(
source.getOid(), MODULE_NAME, MOVE_NOTIFICATION,
new Object[] { new Integer(zoneId), new Integer(sceneId) });
}
/** The invocation manager with which we interact. */
protected InvocationManager _invmgr;
/** The zone registry with which we communicate. */
protected ZoneRegistry _zonereg;
@@ -1,5 +1,5 @@
//
// $Id: ZoneRegistry.java,v 1.6 2002/03/28 23:59:33 mdb Exp $
// $Id: ZoneRegistry.java,v 1.7 2002/05/26 02:24:46 mdb Exp $
package com.threerings.whirled.zone.server;
@@ -24,7 +24,7 @@ public class ZoneRegistry
{
// create a zone provider and register it with the invocation
// services
ZoneProvider provider = new ZoneProvider(this, screg);
ZoneProvider provider = new ZoneProvider(invmgr, this, screg);
invmgr.registerProvider(ZoneProvider.MODULE_NAME, provider);
}