From 64bed2eb126d36a2263404cf174ea4ded8565a8c Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 1 Oct 2001 22:16:02 +0000 Subject: [PATCH] Created SceneCodes, moved scene invocation service codes into there. Changed SceneManager to SceneDirector. Updated to deal with LocationManager name change. Clean, clean, clean. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@369 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/whirled/client/SceneCodes.java | 15 +++++++++++++ .../whirled/client/SceneDirector.java | 19 ++++++++-------- .../whirled/client/SceneService.java | 11 ++++------ .../whirled/server/SceneProvider.java | 18 ++++++++------- .../whirled/util/WhirledContext.java | 8 +++---- .../com/threerings/whirled/TestClient.java | 22 +++++++++---------- 6 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 src/java/com/threerings/whirled/client/SceneCodes.java diff --git a/src/java/com/threerings/whirled/client/SceneCodes.java b/src/java/com/threerings/whirled/client/SceneCodes.java new file mode 100644 index 000000000..6a8fdf57a --- /dev/null +++ b/src/java/com/threerings/whirled/client/SceneCodes.java @@ -0,0 +1,15 @@ +// +// $Id: SceneCodes.java,v 1.1 2001/10/01 22:16:02 mdb Exp $ + +package com.threerings.whirled.client; + +import com.threerings.cocktail.party.client.LocationCodes; + +/** + * Contains codes used by the scene invocation services. + */ +public interface SceneCodes extends LocationCodes +{ + /** The module name for the scene services. */ + public static final String MODULE_NAME = "whirled!scene"; +} diff --git a/src/java/com/threerings/whirled/client/SceneDirector.java b/src/java/com/threerings/whirled/client/SceneDirector.java index 4d90aa4a0..3dc1c6489 100644 --- a/src/java/com/threerings/whirled/client/SceneDirector.java +++ b/src/java/com/threerings/whirled/client/SceneDirector.java @@ -1,5 +1,5 @@ // -// $Id: SceneDirector.java,v 1.2 2001/08/15 02:13:12 mdb Exp $ +// $Id: SceneDirector.java,v 1.3 2001/10/01 22:16:02 mdb Exp $ package com.threerings.whirled.client; @@ -9,7 +9,7 @@ import com.threerings.cocktail.cher.dobj.DObject; import com.threerings.cocktail.cher.dobj.ObjectAccessException; import com.threerings.cocktail.cher.util.IntMap; -import com.threerings.cocktail.party.client.LocationManager; +import com.threerings.cocktail.party.client.LocationDirector; import com.threerings.cocktail.party.client.LocationObserver; import com.threerings.cocktail.party.data.PlaceObject; @@ -20,24 +20,25 @@ import com.threerings.whirled.data.Scene; import com.threerings.whirled.util.WhirledContext; /** - * The scene manager is the client's interface to all things scene + * The scene director is the client's interface to all things scene * related. It interfaces with the scene repository to ensure that scene * objects are available when the client enters a particular scene. It * handles moving from scene to scene (it extends and replaces the - * location manager in order to do this). + * location director in order to do this). * - *

Note that when the scene manager is in use instead of the location - * manager, scene ids instead of place oids will be supplied to {@link + *

Note that when the scene director is in use instead of the location + * director, scene ids instead of place oids will be supplied to {@link * com.threerings.cocktail.party.client.LocationObserver#locationMayChange} * and {@link * com.threerings.cocktail.party.client.LocationObserver#locationChangeFailed}. */ -public class SceneManager extends LocationManager +public class SceneDirector + extends LocationDirector implements SceneCodes { /** - * Creates a new scene manager with the specified context. + * Creates a new scene director with the specified context. */ - public SceneManager (WhirledContext ctx, SceneRepository screp) + public SceneDirector (WhirledContext ctx, SceneRepository screp) { super(ctx); diff --git a/src/java/com/threerings/whirled/client/SceneService.java b/src/java/com/threerings/whirled/client/SceneService.java index bc3453653..219486aaa 100644 --- a/src/java/com/threerings/whirled/client/SceneService.java +++ b/src/java/com/threerings/whirled/client/SceneService.java @@ -1,5 +1,5 @@ // -// $Id: SceneService.java,v 1.2 2001/08/14 06:51:07 mdb Exp $ +// $Id: SceneService.java,v 1.3 2001/10/01 22:16:02 mdb Exp $ package com.threerings.whirled.client; @@ -12,11 +12,8 @@ import com.threerings.whirled.Log; * The scene service class provides the client interface to the scene * related invocation services (e.g. moving from scene to scene). */ -public class SceneService +public class SceneService implements SceneCodes { - /** The module name for the scene services. */ - public static final String MODULE = "whirled!scene"; - /** * Requests that that this client's body be moved to the specified * scene. @@ -26,12 +23,12 @@ public class SceneService * have in our local repository. */ public static void moveTo (Client client, int sceneId, - int sceneVers, SceneManager rsptarget) + int sceneVers, SceneDirector rsptarget) { InvocationManager invmgr = client.getInvocationManager(); Object[] args = new Object[] { new Integer(sceneId), new Integer(sceneVers) }; - invmgr.invoke(MODULE, "MoveTo", args, rsptarget); + invmgr.invoke(MODULE_NAME, MOVE_TO_REQUEST, args, rsptarget); Log.info("Sent moveTo request [scene=" + sceneId + ", version=" + sceneVers + "]."); } diff --git a/src/java/com/threerings/whirled/server/SceneProvider.java b/src/java/com/threerings/whirled/server/SceneProvider.java index f56ecf31d..668b3b3c3 100644 --- a/src/java/com/threerings/whirled/server/SceneProvider.java +++ b/src/java/com/threerings/whirled/server/SceneProvider.java @@ -1,22 +1,23 @@ // -// $Id: SceneProvider.java,v 1.1 2001/08/11 04:09:50 mdb Exp $ +// $Id: SceneProvider.java,v 1.2 2001/10/01 22:16:02 mdb Exp $ package com.threerings.whirled.server; import com.threerings.cocktail.cher.server.InvocationProvider; -import com.threerings.cocktail.cher.util.Codes; import com.threerings.cocktail.party.data.BodyObject; import com.threerings.cocktail.party.data.PlaceObject; import com.threerings.cocktail.party.server.LocationProvider; import com.threerings.whirled.Log; +import com.threerings.whirled.client.SceneCodes; /** * The scene provider handles the server side of the scene related * invocation services (e.g. moving from scene to scene). */ -public class SceneProvider extends InvocationProvider +public class SceneProvider + extends InvocationProvider implements SceneCodes { /** * Processes a request from a client to move to a new scene. @@ -45,8 +46,8 @@ public class SceneProvider extends InvocationProvider Log.warning("Unable to resolve scene [sceneid=" + rsceneId + ", reason=" + reason + "]."); // pretend like the scene doesn't exist to the client - sendResponse(fsource, finvid, "MoveFailed", - "m.no_such_place"); + sendResponse(fsource, finvid, MOVE_FAILED_RESPONSE, + NO_SUCH_PLACE); } }; @@ -70,14 +71,15 @@ public class SceneProvider extends InvocationProvider String rcode = LocationProvider.moveTo(source, ploid); // if the move failed, let them know - if (!rcode.equals(Codes.SUCCESS)) { - sendResponse(source, invid, "MoveFailed", rcode); + if (!rcode.equals(SUCCESS)) { + sendResponse(source, invid, MOVE_FAILED_RESPONSE, rcode); return; } // otherwise check to see if they need a newer version of the // scene data - sendResponse(source, invid, "MoveSucceeded", new Integer(ploid)); + sendResponse(source, invid, MOVE_SUCCEEDED_RESPONSE, + new Integer(ploid)); } } diff --git a/src/java/com/threerings/whirled/util/WhirledContext.java b/src/java/com/threerings/whirled/util/WhirledContext.java index 4947ec62b..29c82f132 100644 --- a/src/java/com/threerings/whirled/util/WhirledContext.java +++ b/src/java/com/threerings/whirled/util/WhirledContext.java @@ -1,10 +1,10 @@ // -// $Id: WhirledContext.java,v 1.1 2001/08/14 06:51:07 mdb Exp $ +// $Id: WhirledContext.java,v 1.2 2001/10/01 22:16:02 mdb Exp $ package com.threerings.whirled.util; import com.threerings.cocktail.party.util.PartyContext; -import com.threerings.whirled.client.SceneManager; +import com.threerings.whirled.client.SceneDirector; /** * The whirled context provides access to the various managers, etc. that @@ -13,7 +13,7 @@ import com.threerings.whirled.client.SceneManager; public interface WhirledContext extends PartyContext { /** - * Returns a reference to the scene manager. + * Returns a reference to the scene director. */ - public SceneManager getSceneManager (); + public SceneDirector getSceneDirector (); } diff --git a/tests/src/java/com/threerings/whirled/TestClient.java b/tests/src/java/com/threerings/whirled/TestClient.java index 64814db96..d744b5700 100644 --- a/tests/src/java/com/threerings/whirled/TestClient.java +++ b/tests/src/java/com/threerings/whirled/TestClient.java @@ -1,5 +1,5 @@ // -// $Id: TestClient.java,v 1.2 2001/08/20 22:10:49 mdb Exp $ +// $Id: TestClient.java,v 1.3 2001/10/01 22:16:02 mdb Exp $ package com.threerings.whirled.client.test; @@ -14,7 +14,7 @@ import com.threerings.cocktail.party.Log; import com.threerings.cocktail.party.client.*; import com.threerings.cocktail.party.data.PlaceObject; -import com.threerings.whirled.client.SceneManager; +import com.threerings.whirled.client.SceneDirector; import com.threerings.whirled.client.persist.SceneRepository; import com.threerings.whirled.util.WhirledContext; @@ -31,13 +31,13 @@ public class TestClient _client = new Client(creds, this); _screp = new DummySceneRepository(); _occmgr = new OccupantManager(_ctx); - _scmgr = new SceneManager(_ctx, _screp); + _scdir = new SceneDirector(_ctx, _screp); // we want to know about logon/logoff _client.addObserver(this); // we want to know about location changes - _scmgr.addLocationObserver(this); + _scdir.addLocationObserver(this); // for test purposes, hardcode the server info _client.setServer("localhost", 4007); @@ -66,7 +66,7 @@ public class TestClient Log.info("Client did logon [client=" + client + "]."); // request to move to scene 0 - _ctx.getSceneManager().moveTo(0); + _ctx.getSceneDirector().moveTo(0); } public void clientFailedToLogon (Client client, Exception cause) @@ -102,7 +102,7 @@ public class TestClient public void locationDidChange (PlaceObject place) { Log.info("At new location [plobj=" + place + - ", scene=" + _scmgr.getScene() + "]."); + ", scene=" + _scdir.getScene() + "]."); } public void locationChangeFailed (int placeId, String reason) @@ -138,9 +138,9 @@ public class TestClient return _client.getDObjectManager(); } - public LocationManager getLocationManager () + public LocationDirector getLocationDirector () { - return _scmgr; + return _scdir; } public OccupantManager getOccupantManager () @@ -148,15 +148,15 @@ public class TestClient return _occmgr; } - public SceneManager getSceneManager () + public SceneDirector getSceneDirector () { - return _scmgr; + return _scdir; } } protected Config _config; protected Client _client; - protected SceneManager _scmgr; + protected SceneDirector _scdir; protected OccupantManager _occmgr; protected SceneRepository _screp; protected WhirledContext _ctx;