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:
@@ -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;
|
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.dobj.ObjectAccessException;
|
||||||
import com.threerings.cocktail.cher.util.IntMap;
|
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.client.LocationObserver;
|
||||||
import com.threerings.cocktail.party.data.PlaceObject;
|
import com.threerings.cocktail.party.data.PlaceObject;
|
||||||
|
|
||||||
@@ -20,24 +20,25 @@ import com.threerings.whirled.data.Scene;
|
|||||||
import com.threerings.whirled.util.WhirledContext;
|
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
|
* related. It interfaces with the scene repository to ensure that scene
|
||||||
* objects are available when the client enters a particular scene. It
|
* objects are available when the client enters a particular scene. It
|
||||||
* handles moving from scene to scene (it extends and replaces the
|
* 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
|
* <p> Note that when the scene director is in use instead of the location
|
||||||
* manager, scene ids instead of place oids will be supplied to {@link
|
* director, scene ids instead of place oids will be supplied to {@link
|
||||||
* com.threerings.cocktail.party.client.LocationObserver#locationMayChange}
|
* com.threerings.cocktail.party.client.LocationObserver#locationMayChange}
|
||||||
* and {@link
|
* and {@link
|
||||||
* com.threerings.cocktail.party.client.LocationObserver#locationChangeFailed}.
|
* 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);
|
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;
|
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
|
* The scene service class provides the client interface to the scene
|
||||||
* related invocation services (e.g. moving from scene to 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
|
* Requests that that this client's body be moved to the specified
|
||||||
* scene.
|
* scene.
|
||||||
@@ -26,12 +23,12 @@ public class SceneService
|
|||||||
* have in our local repository.
|
* have in our local repository.
|
||||||
*/
|
*/
|
||||||
public static void moveTo (Client client, int sceneId,
|
public static void moveTo (Client client, int sceneId,
|
||||||
int sceneVers, SceneManager rsptarget)
|
int sceneVers, SceneDirector rsptarget)
|
||||||
{
|
{
|
||||||
InvocationManager invmgr = client.getInvocationManager();
|
InvocationManager invmgr = client.getInvocationManager();
|
||||||
Object[] args = new Object[] {
|
Object[] args = new Object[] {
|
||||||
new Integer(sceneId), new Integer(sceneVers) };
|
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 +
|
Log.info("Sent moveTo request [scene=" + sceneId +
|
||||||
", version=" + sceneVers + "].");
|
", 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;
|
package com.threerings.whirled.server;
|
||||||
|
|
||||||
import com.threerings.cocktail.cher.server.InvocationProvider;
|
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.BodyObject;
|
||||||
import com.threerings.cocktail.party.data.PlaceObject;
|
import com.threerings.cocktail.party.data.PlaceObject;
|
||||||
import com.threerings.cocktail.party.server.LocationProvider;
|
import com.threerings.cocktail.party.server.LocationProvider;
|
||||||
|
|
||||||
import com.threerings.whirled.Log;
|
import com.threerings.whirled.Log;
|
||||||
|
import com.threerings.whirled.client.SceneCodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The scene provider handles the server side of the scene related
|
* The scene provider handles the server side of the scene related
|
||||||
* invocation services (e.g. moving from scene to scene).
|
* 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.
|
* 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 +
|
Log.warning("Unable to resolve scene [sceneid=" + rsceneId +
|
||||||
", reason=" + reason + "].");
|
", reason=" + reason + "].");
|
||||||
// pretend like the scene doesn't exist to the client
|
// pretend like the scene doesn't exist to the client
|
||||||
sendResponse(fsource, finvid, "MoveFailed",
|
sendResponse(fsource, finvid, MOVE_FAILED_RESPONSE,
|
||||||
"m.no_such_place");
|
NO_SUCH_PLACE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,14 +71,15 @@ public class SceneProvider extends InvocationProvider
|
|||||||
String rcode = LocationProvider.moveTo(source, ploid);
|
String rcode = LocationProvider.moveTo(source, ploid);
|
||||||
|
|
||||||
// if the move failed, let them know
|
// if the move failed, let them know
|
||||||
if (!rcode.equals(Codes.SUCCESS)) {
|
if (!rcode.equals(SUCCESS)) {
|
||||||
sendResponse(source, invid, "MoveFailed", rcode);
|
sendResponse(source, invid, MOVE_FAILED_RESPONSE, rcode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise check to see if they need a newer version of the
|
// otherwise check to see if they need a newer version of the
|
||||||
// scene data
|
// 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;
|
package com.threerings.whirled.util;
|
||||||
|
|
||||||
import com.threerings.cocktail.party.util.PartyContext;
|
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
|
* 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
|
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 ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
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.client.*;
|
||||||
import com.threerings.cocktail.party.data.PlaceObject;
|
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.client.persist.SceneRepository;
|
||||||
import com.threerings.whirled.util.WhirledContext;
|
import com.threerings.whirled.util.WhirledContext;
|
||||||
|
|
||||||
@@ -31,13 +31,13 @@ public class TestClient
|
|||||||
_client = new Client(creds, this);
|
_client = new Client(creds, this);
|
||||||
_screp = new DummySceneRepository();
|
_screp = new DummySceneRepository();
|
||||||
_occmgr = new OccupantManager(_ctx);
|
_occmgr = new OccupantManager(_ctx);
|
||||||
_scmgr = new SceneManager(_ctx, _screp);
|
_scdir = new SceneDirector(_ctx, _screp);
|
||||||
|
|
||||||
// we want to know about logon/logoff
|
// we want to know about logon/logoff
|
||||||
_client.addObserver(this);
|
_client.addObserver(this);
|
||||||
|
|
||||||
// we want to know about location changes
|
// we want to know about location changes
|
||||||
_scmgr.addLocationObserver(this);
|
_scdir.addLocationObserver(this);
|
||||||
|
|
||||||
// for test purposes, hardcode the server info
|
// for test purposes, hardcode the server info
|
||||||
_client.setServer("localhost", 4007);
|
_client.setServer("localhost", 4007);
|
||||||
@@ -66,7 +66,7 @@ public class TestClient
|
|||||||
Log.info("Client did logon [client=" + client + "].");
|
Log.info("Client did logon [client=" + client + "].");
|
||||||
|
|
||||||
// request to move to scene 0
|
// request to move to scene 0
|
||||||
_ctx.getSceneManager().moveTo(0);
|
_ctx.getSceneDirector().moveTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clientFailedToLogon (Client client, Exception cause)
|
public void clientFailedToLogon (Client client, Exception cause)
|
||||||
@@ -102,7 +102,7 @@ public class TestClient
|
|||||||
public void locationDidChange (PlaceObject place)
|
public void locationDidChange (PlaceObject place)
|
||||||
{
|
{
|
||||||
Log.info("At new location [plobj=" + place +
|
Log.info("At new location [plobj=" + place +
|
||||||
", scene=" + _scmgr.getScene() + "].");
|
", scene=" + _scdir.getScene() + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void locationChangeFailed (int placeId, String reason)
|
public void locationChangeFailed (int placeId, String reason)
|
||||||
@@ -138,9 +138,9 @@ public class TestClient
|
|||||||
return _client.getDObjectManager();
|
return _client.getDObjectManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocationManager getLocationManager ()
|
public LocationDirector getLocationDirector ()
|
||||||
{
|
{
|
||||||
return _scmgr;
|
return _scdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OccupantManager getOccupantManager ()
|
public OccupantManager getOccupantManager ()
|
||||||
@@ -148,15 +148,15 @@ public class TestClient
|
|||||||
return _occmgr;
|
return _occmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SceneManager getSceneManager ()
|
public SceneDirector getSceneDirector ()
|
||||||
{
|
{
|
||||||
return _scmgr;
|
return _scdir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Config _config;
|
protected Config _config;
|
||||||
protected Client _client;
|
protected Client _client;
|
||||||
protected SceneManager _scmgr;
|
protected SceneDirector _scdir;
|
||||||
protected OccupantManager _occmgr;
|
protected OccupantManager _occmgr;
|
||||||
protected SceneRepository _screp;
|
protected SceneRepository _screp;
|
||||||
protected WhirledContext _ctx;
|
protected WhirledContext _ctx;
|
||||||
|
|||||||
Reference in New Issue
Block a user