Major surgery to bring Whirled into line with the new PlaceConfig world

order. Also moved stuff from whirled.client.test and whirled.server.test
into whirled.test because it's silly having two separate test directories.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@401 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-10-05 23:59:37 +00:00
parent 09ef3cd972
commit 7d02b3d30b
13 changed files with 97 additions and 49 deletions
@@ -1,5 +1,5 @@
//
// $Id: SceneDirector.java,v 1.4 2001/10/02 02:08:16 mdb Exp $
// $Id: SceneDirector.java,v 1.5 2001/10/05 23:59:36 mdb Exp $
package com.threerings.whirled.client;
@@ -11,6 +11,7 @@ import com.threerings.cocktail.cher.dobj.ObjectAccessException;
import com.threerings.cocktail.party.client.LocationDirector;
import com.threerings.cocktail.party.client.LocationObserver;
import com.threerings.cocktail.party.data.PlaceConfig;
import com.threerings.cocktail.party.data.PlaceObject;
import com.threerings.whirled.Log;
@@ -101,11 +102,12 @@ public class SceneDirector
/**
* Called in response to a successful <code>moveTo</code> request.
*/
public void handleMoveSucceeded (int invid, int placeId)
public void handleMoveSucceeded (
int invid, int placeId, PlaceConfig config)
{
// our move request was successful, deal with subscribing to our
// new place object
didMoveTo(placeId);
didMoveTo(placeId, config);
// since we're committed to moving to the new scene, we'll
// parallelize and go ahead and load up the new scene now rather
@@ -1,8 +1,9 @@
//
// $Id: DummyScene.java,v 1.3 2001/09/21 00:21:40 mdb Exp $
// $Id: DummyScene.java,v 1.4 2001/10/05 23:59:37 mdb Exp $
package com.threerings.whirled.client.test;
package com.threerings.whirled.test;
import com.threerings.cocktail.party.data.PlaceConfig;
import com.threerings.whirled.data.Scene;
public class DummyScene implements Scene
@@ -32,5 +33,10 @@ public class DummyScene implements Scene
return null;
}
public PlaceConfig getPlaceConfig ()
{
return new TestConfig();
}
protected int _sceneId;
}
@@ -1,5 +1,5 @@
//
// $Id: EditableScene.java,v 1.2 2001/09/28 01:46:10 mdb Exp $
// $Id: EditableScene.java,v 1.3 2001/10/05 23:59:36 mdb Exp $
package com.threerings.whirled.data;
@@ -19,9 +19,4 @@ public interface EditableScene extends Scene
* Updates the scene's version.
*/
public void setVersion (int version);
/**
* Updates the scene's name.
*/
public void setName (String name);
}
@@ -1,17 +1,16 @@
//
// $Id: Scene.java,v 1.4 2001/09/21 02:30:35 mdb Exp $
// $Id: Scene.java,v 1.5 2001/10/05 23:59:36 mdb Exp $
package com.threerings.whirled.data;
import com.threerings.cocktail.party.data.PlaceConfig;
/**
* The base scene interface. This encapsulates the minimum information
* needed about a scene in the Whirled system.
*/
public interface Scene
{
/** Scene id to denote an unset or otherwise invalid scene id. */
public static final int SID_INVALID = -1;
/**
* Returns the scene's unique identifier.
*/
@@ -25,15 +24,22 @@ public interface Scene
*/
public int getVersion ();
/**
* Returns the scene's name. Every scene has a descriptive name.
*/
public String getName ();
/**
* Returns the scene ids of all scenes that neighbor this scene. A
* neighboring scene is one to which the user can traverse from this
* scene and vice versa.
*/
public int[] getNeighborIds ();
/**
* A scene is associated with a place on the server. Because the
* scenes are loaded on demand, the scene implementation must be able
* to provide a place config instance for each scene. This will allow
* the server to figure out what manager class to instantiate to
* manage the scene and all the client to figure out what controller
* class to instantiate to controll the scene. Additionally, it may
* contain runtime configuration information needed by the application
* using the Whirled services.
*/
public PlaceConfig getPlaceConfig ();
}
@@ -1,5 +1,5 @@
//
// $Id: SceneManager.java,v 1.4 2001/09/05 01:08:30 shaper Exp $
// $Id: SceneManager.java,v 1.5 2001/10/05 23:59:36 mdb Exp $
package com.threerings.whirled.server;
@@ -11,6 +11,10 @@ import com.threerings.whirled.data.Scene;
public class SceneManager extends PlaceManager
{
/**
* Returns the scene object (not the scene distributed object)
* associated with this scene.
*/
public Scene getScene ()
{
return _scene;
@@ -1,12 +1,12 @@
//
// $Id: SceneProvider.java,v 1.2 2001/10/01 22:16:02 mdb Exp $
// $Id: SceneProvider.java,v 1.3 2001/10/05 23:59:36 mdb Exp $
package com.threerings.whirled.server;
import com.threerings.cocktail.cher.server.InvocationProvider;
import com.threerings.cocktail.cher.server.ServiceFailedException;
import com.threerings.cocktail.party.data.BodyObject;
import com.threerings.cocktail.party.data.PlaceObject;
import com.threerings.cocktail.party.data.*;
import com.threerings.cocktail.party.server.LocationProvider;
import com.threerings.whirled.Log;
@@ -67,19 +67,19 @@ public class SceneProvider
PlaceObject plobj = scmgr.getPlaceObject();
int ploid = plobj.getOid();
// try doing the actual move
String rcode = LocationProvider.moveTo(source, ploid);
try {
// try doing the actual move
PlaceConfig config = LocationProvider.moveTo(source, ploid);
// if the move failed, let them know
if (!rcode.equals(SUCCESS)) {
sendResponse(source, invid, MOVE_FAILED_RESPONSE, rcode);
return;
// check to see if they need a newer version of the scene data
// then send the moveTo response
sendResponse(source, invid, MOVE_SUCCEEDED_RESPONSE,
new Integer(ploid), config);
} catch (ServiceFailedException sfe) {
sendResponse(source, invid, MOVE_FAILED_RESPONSE,
sfe.getMessage());
}
// otherwise check to see if they need a newer version of the
// scene data
sendResponse(source, invid, MOVE_SUCCEEDED_RESPONSE,
new Integer(ploid));
}
}
@@ -1,5 +1,5 @@
//
// $Id: SceneRegistry.java,v 1.3 2001/10/02 02:08:16 mdb Exp $
// $Id: SceneRegistry.java,v 1.4 2001/10/05 23:59:36 mdb Exp $
package com.threerings.whirled.server;
@@ -76,7 +76,7 @@ public class SceneRegistry
* active. The supplied callback instance will be notified, on the
* dobjmgr thread, when the scene has been resolved. If the scene is
* already active, it will be notified immediately (before the call to
* <code>resolveScene</code> returns).
* {@link #resolveScene} returns).
*
* @param sceneId the id of the scene to resolve.
* @param resolver a reference to a callback instance that will be
@@ -161,7 +161,7 @@ public class SceneRegistry
try {
SceneManager scmgr = (SceneManager)
PartyServer.plreg.createPlace(SceneManager.class);
PartyServer.plreg.createPlace(scene.getPlaceConfig());
// configure the scene manager with references to useful
// stuff; we'll somehow need to convey configuration
@@ -1,5 +1,5 @@
//
// $Id: WhirledServer.java,v 1.5 2001/10/02 02:08:16 mdb Exp $
// $Id: WhirledServer.java,v 1.6 2001/10/05 23:59:36 mdb Exp $
package com.threerings.whirled.server;
@@ -11,7 +11,7 @@ import com.threerings.cocktail.party.server.PartyServer;
import com.threerings.whirled.Log;
import com.threerings.whirled.server.persist.SceneRepository;
import com.threerings.whirled.server.test.DummySceneRepository;
import com.threerings.whirled.test.DummySceneRepository;
/**
* The whirled server extends the party server and provides access to
@@ -1,7 +1,7 @@
//
// $Id: DummySceneRepository.java,v 1.3 2001/09/21 03:15:02 mdb Exp $
// $Id: DummySceneRepository.java,v 1.4 2001/10/05 23:59:37 mdb Exp $
package com.threerings.whirled.server.test;
package com.threerings.whirled.test;
import com.samskivert.io.PersistenceException;
@@ -1,7 +1,7 @@
//
// $Id: DummyClientSceneRepository.java,v 1.1 2001/08/14 06:51:07 mdb Exp $
// $Id: DummyClientSceneRepository.java,v 1.2 2001/10/05 23:59:37 mdb Exp $
package com.threerings.whirled.client.test;
package com.threerings.whirled.test;
import java.io.IOException;
@@ -15,7 +15,7 @@ import com.threerings.whirled.util.NoSuchSceneException;
* in fact it just creates new blank scenes when requested to load a scene
* and does nothing when requested to save one.
*/
public class DummySceneRepository implements SceneRepository
public class DummyClientSceneRepository implements SceneRepository
{
// documentation inherited
public Scene loadScene (int sceneId)
@@ -1,7 +1,7 @@
//
// $Id: TestClient.java,v 1.3 2001/10/01 22:16:02 mdb Exp $
// $Id: TestClient.java,v 1.4 2001/10/05 23:59:37 mdb Exp $
package com.threerings.whirled.client.test;
package com.threerings.whirled.test;
import com.samskivert.util.Config;
import com.samskivert.util.Queue;
@@ -29,7 +29,7 @@ public class TestClient
// create the handles for our various services
_config = new Config();
_client = new Client(creds, this);
_screp = new DummySceneRepository();
_screp = new DummyClientSceneRepository();
_occmgr = new OccupantManager(_ctx);
_scdir = new SceneDirector(_ctx, _screp);
@@ -0,0 +1,20 @@
//
// $Id: TestConfig.java,v 1.1 2001/10/05 23:59:37 mdb Exp $
package com.threerings.whirled.test;
import com.threerings.cocktail.party.data.PlaceConfig;
import com.threerings.whirled.server.SceneManager;
public class TestConfig extends PlaceConfig
{
public Class getControllerClass ()
{
return TestController.class;
}
public String getManagerClassName ()
{
return SceneManager.class.getName();
}
}
@@ -0,0 +1,15 @@
//
// $Id: TestController.java,v 1.1 2001/10/05 23:59:37 mdb Exp $
package com.threerings.whirled.test;
import com.threerings.cocktail.party.client.*;
public class TestController extends PlaceController
{
protected PlaceView createPlaceView ()
{
// nothing doing
return null;
}
}