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
This commit is contained in:
Michael Bayne
2001-10-01 22:16:02 +00:00
parent 027bb29769
commit 64bed2eb12
6 changed files with 54 additions and 39 deletions
@@ -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";
}
@@ -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).
*
* <p> 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
* <p> 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);
@@ -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 + "].");
}
@@ -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));
}
}
@@ -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 ();
}