The great invocation services rethink of 2002! Rearchitected the remote

method invocation services and converted everything to the new style.
Could this be my biggest checkin ever?


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1642 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-08-14 19:08:01 +00:00
parent 4481c5f835
commit e54a4d41f4
161 changed files with 6083 additions and 2805 deletions
@@ -0,0 +1,52 @@
//
// $Id: SceneDecoder.java,v 1.1 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.client;
import com.threerings.presents.client.InvocationDecoder;
import com.threerings.whirled.client.SceneReceiver;
/**
* Dispatches calls to a {@link SceneReceiver} instance.
*/
public class SceneDecoder extends InvocationDecoder
{
/** The generated hash code used to identify this receiver class. */
public static final String RECEIVER_CODE = "c4d0cf66b81a6e83d119b2d607725651";
/** The method id used to dispatch {@link SceneReceiver#forcedMove}
* notifications. */
public static final int FORCED_MOVE = 1;
/**
* Creates a decoder that may be registered to dispatch invocation
* service notifications to the specified receiver.
*/
public SceneDecoder (SceneReceiver receiver)
{
this.receiver = receiver;
}
// documentation inherited
public String getReceiverCode ()
{
return RECEIVER_CODE;
}
// documentation inherited
public void dispatchNotification (int methodId, Object[] args)
{
switch (methodId) {
case FORCED_MOVE:
((SceneReceiver)receiver).forcedMove(
((Integer)args[0]).intValue()
);
return;
default:
super.dispatchNotification(methodId, args);
}
}
// Generated on 11:25:48 08/12/02.
}
@@ -1,5 +1,5 @@
//
// $Id: SceneDirector.java,v 1.19 2002/06/14 01:40:16 ray Exp $
// $Id: SceneDirector.java,v 1.20 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.client;
@@ -7,9 +7,8 @@ import java.io.IOException;
import com.samskivert.util.HashIntMap;
import com.samskivert.util.ResultListener;
import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationReceiver;
import com.threerings.presents.client.SessionObserver;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.ObjectAccessException;
@@ -37,9 +36,9 @@ import com.threerings.whirled.util.WhirledContext;
* LocationObserver#locationMayChange} and {@link
* LocationObserver#locationChangeFailed}.
*/
public class SceneDirector
implements SceneCodes, SessionObserver, LocationDirector.FailureHandler,
InvocationReceiver
public class SceneDirector extends BasicDirector
implements SceneCodes, LocationDirector.FailureHandler,
SceneReceiver, SceneService.SceneMoveListener
{
/**
* Creates a new scene director with the specified context.
@@ -55,6 +54,8 @@ public class SceneDirector
public SceneDirector (WhirledContext ctx, LocationDirector locdir,
SceneRepository screp, DisplaySceneFactory dsfact)
{
super(ctx);
// we'll need these for later
_ctx = ctx;
_locdir = locdir;
@@ -65,13 +66,9 @@ public class SceneDirector
// director because we need to do special processing
_locdir.setFailureHandler(this);
// register ourselves as a client observer so that we can clear
// out our scene when the client logs off
_ctx.getClient().addClientObserver(this);
// register for scene notifications
_ctx.getClient().getInvocationDirector().registerReceiver(
MODULE_NAME, this);
new SceneDecoder(this));
}
/**
@@ -115,7 +112,7 @@ public class SceneDirector
}
// issue a moveTo request
SceneService.moveTo(_ctx.getClient(), sceneId, sceneVers, this);
_sservice.moveTo(_ctx.getClient(), sceneId, sceneVers, this);
return true;
}
@@ -176,11 +173,8 @@ public class SceneDirector
return _pendingModel;
}
/**
* Called in response to a successful <code>moveTo</code> request.
*/
public void handleMoveSucceeded (
int invid, int placeId, PlaceConfig config)
// documentation inherited from interface
public void moveSucceeded (int placeId, PlaceConfig config)
{
// our move request was successful, deal with subscribing to our
// new place object
@@ -214,13 +208,9 @@ public class SceneDirector
_scene = _dsfact.createScene(_model, config);
}
/**
* Called in response to a successful <code>moveTo</code> request when
* our cached scene was out of date and the server determined that we
* needed an updated copy.
*/
public void handleMoveSucceededPlusUpdate (
int invid, int placeId, PlaceConfig config, SceneModel model)
// documentation inherited from interface
public void moveSucceededPlusUpdate (
int placeId, PlaceConfig config, SceneModel model)
{
// update the model in the repository
try {
@@ -237,13 +227,11 @@ public class SceneDirector
_scache.put(model.sceneId, model);
// and pass through to the normal move succeeded handler
handleMoveSucceeded(invid, placeId, config);
moveSucceeded(placeId, config);
}
/**
* Called in response to a failed <code>moveTo</code> request.
*/
public void handleMoveFailed (int invid, String reason)
// documentation inherited from interface
public void requestFailed (String reason)
{
// clear out our pending request oid
int sceneId = _pendingSceneId;
@@ -266,13 +254,8 @@ public class SceneDirector
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)
// documentation inherited from interface
public void forcedMove (int sceneId)
{
Log.info("Moving at request of server [sceneId=" + sceneId + "].");
@@ -361,20 +344,26 @@ public class SceneDirector
}
// documentation inherited from interface
public void clientDidLogon (Client client)
public void clientDidLogoff (Client client)
{
// nothing for now
super.clientDidLogoff(client);
clearScene();
}
// documentation inherited from interface
public void clientDidLogoff (Client client)
protected void fetchServices (Client client)
{
clearScene();
// get a handle on our scene service
_sservice = (SceneService)client.requireService(SceneService.class);
}
/** Access to general client services. */
protected WhirledContext _ctx;
/** Access to our scene services. */
protected SceneService _sservice;
/** The client's active location director. */
protected LocationDirector _locdir;
@@ -0,0 +1,21 @@
//
// $Id: SceneReceiver.java,v 1.1 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.client;
import com.threerings.presents.client.InvocationReceiver;
/**
* Defines, for the scene services, a set of notifications delivered
* asynchronously by the server to the client.
*/
public interface SceneReceiver extends InvocationReceiver
{
/**
* Used to communicate a required move notification to the client. The
* server will have removed the client from their existing scene
* and the client is then responsible for generating a {@link
* SceneService#moveTo} request to move to the new scene.
*/
public void forcedMove (int sceneId);
}
@@ -1,20 +1,46 @@
//
// $Id: SceneService.java,v 1.8 2002/05/15 23:54:34 mdb Exp $
// $Id: SceneService.java,v 1.9 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.client;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationDirector;
import com.threerings.presents.client.InvocationService;
import com.threerings.whirled.Log;
import com.threerings.whirled.data.SceneCodes;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.whirled.data.SceneModel;
/**
* The scene service class provides the client interface to the scene
* related invocation services (e.g. moving from scene to scene).
*/
public class SceneService implements SceneCodes
public interface SceneService extends InvocationService
{
/**
* Used to communicate the response to a {@link #moveTo} request.
*/
public static interface SceneMoveListener extends InvocationListener
{
/**
* Indicates that a move succeeded.
*
* @param placeId the place object id of the newly occupied scene.
* @param config metadata related to the newly occupied scene.
*/
public void moveSucceeded (int placeId, PlaceConfig config);
/**
* Indicates that a move succeeded and that the client's cached
* scene information should be updated with the supplied data.
*
* @param placeId the place object id of the newly occupied scene.
* @param config metadata related to the newly occupied scene.
* @param model the most recent scene data for the newly occupied
* scene.
*/
public void moveSucceededPlusUpdate (
int placeId, PlaceConfig config, SceneModel model);
}
/**
* Requests that that this client's body be moved to the specified
* scene.
@@ -23,14 +49,6 @@ public class SceneService implements SceneCodes
* @param sceneVers the version number of the scene object that we
* have in our local repository.
*/
public static void moveTo (Client client, int sceneId,
int sceneVers, Object rsptarget)
{
InvocationDirector invdir = client.getInvocationDirector();
Object[] args = new Object[] {
new Integer(sceneId), new Integer(sceneVers) };
invdir.invoke(MODULE_NAME, MOVE_TO_REQUEST, args, rsptarget);
Log.debug("Sent moveTo request [scene=" + sceneId +
", version=" + sceneVers + "].");
}
public void moveTo (Client client, int sceneId,
int sceneVers, SceneMoveListener listener);
}
@@ -1,5 +1,5 @@
//
// $Id: SceneCodes.java,v 1.2 2002/04/15 18:06:20 mdb Exp $
// $Id: SceneCodes.java,v 1.3 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.data;
@@ -11,13 +11,4 @@ import com.threerings.whirled.client.SceneDirector;
*/
public interface SceneCodes extends LocationCodes
{
/** The module name for the scene services. */
public static final String MODULE_NAME = "whirled!scene";
/** The response identifier for a successful moveTo request that
* includes an updated scene model. This is mapped by the invocation
* services to a call to {@link
* SceneDirector#handleMoveSucceededPlusUpdate}. */
public static final String MOVE_SUCCEEDED_PLUS_UPDATE_RESPONSE =
"MoveSucceededPlusUpdate";
}
@@ -0,0 +1,85 @@
//
// $Id: SceneMarshaller.java,v 1.1 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.data;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent;
import com.threerings.whirled.client.SceneService;
import com.threerings.whirled.client.SceneService.SceneMoveListener;
import com.threerings.whirled.data.SceneModel;
/**
* Provides the implementation of the {@link SceneService} interface
* that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back
* to the requesting client.
*/
public class SceneMarshaller extends InvocationMarshaller
implements SceneService
{
// documentation inherited
public static class SceneMoveMarshaller extends ListenerMarshaller
implements SceneMoveListener
{
/** The method id used to dispatch {@link #moveSucceeded}
* responses. */
public static final int MOVE_SUCCEEDED = 0;
// documentation inherited from interface
public void moveSucceeded (int arg1, PlaceConfig arg2)
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, MOVE_SUCCEEDED,
new Object[] { new Integer(arg1), arg2 }));
}
/** The method id used to dispatch {@link #moveSucceededPlusUpdate}
* responses. */
public static final int MOVE_SUCCEEDED_PLUS_UPDATE = 1;
// documentation inherited from interface
public void moveSucceededPlusUpdate (int arg1, PlaceConfig arg2, SceneModel arg3)
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, MOVE_SUCCEEDED_PLUS_UPDATE,
new Object[] { new Integer(arg1), arg2, arg3 }));
}
// documentation inherited
public void dispatchResponse (int methodId, Object[] args)
{
switch (methodId) {
case MOVE_SUCCEEDED:
((SceneMoveListener)listener).moveSucceeded(
((Integer)args[0]).intValue(), (PlaceConfig)args[1]);
return;
case MOVE_SUCCEEDED_PLUS_UPDATE:
((SceneMoveListener)listener).moveSucceededPlusUpdate(
((Integer)args[0]).intValue(), (PlaceConfig)args[1], (SceneModel)args[2]);
return;
default:
super.dispatchResponse(methodId, args);
}
}
}
/** The method id used to dispatch {@link #moveTo} requests. */
public static final int MOVE_TO = 1;
// documentation inherited from interface
public void moveTo (Client arg1, int arg2, int arg3, SceneMoveListener arg4)
{
SceneMoveMarshaller listener4 = new SceneMoveMarshaller();
listener4.listener = arg4;
sendRequest(arg1, MOVE_TO, new Object[] {
new Integer(arg2), new Integer(arg3), listener4
});
}
// Class file generated on 00:26:03 08/11/02.
}
@@ -0,0 +1,54 @@
//
// $Id: SceneDispatcher.java,v 1.1 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.server;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.server.InvocationDispatcher;
import com.threerings.presents.server.InvocationException;
import com.threerings.whirled.client.SceneService;
import com.threerings.whirled.client.SceneService.SceneMoveListener;
import com.threerings.whirled.data.SceneMarshaller;
import com.threerings.whirled.data.SceneModel;
/**
* Dispatches requests to the {@link SceneProvider}.
*/
public class SceneDispatcher extends InvocationDispatcher
{
/**
* Creates a dispatcher that may be registered to dispatch invocation
* service requests for the specified provider.
*/
public SceneDispatcher (SceneProvider provider)
{
this.provider = provider;
}
// documentation inherited
public InvocationMarshaller createMarshaller ()
{
return new SceneMarshaller();
}
// documentation inherited
public void dispatchRequest (
ClientObject source, int methodId, Object[] args)
throws InvocationException
{
switch (methodId) {
case SceneMarshaller.MOVE_TO:
((SceneProvider)provider).moveTo(
source,
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), (SceneMoveListener)args[2]
);
return;
default:
super.dispatchRequest(source, methodId, args);
}
}
}
@@ -1,11 +1,11 @@
//
// $Id: SceneProvider.java,v 1.10 2002/05/26 02:29:13 mdb Exp $
// $Id: SceneProvider.java,v 1.11 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.server;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.presents.server.ServiceFailedException;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig;
@@ -13,6 +13,7 @@ import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.LocationProvider;
import com.threerings.whirled.Log;
import com.threerings.whirled.client.SceneService.SceneMoveListener;
import com.threerings.whirled.data.SceneCodes;
import com.threerings.whirled.data.SceneModel;
@@ -20,29 +21,26 @@ import com.threerings.whirled.data.SceneModel;
* 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
implements SceneCodes
public class SceneProvider
implements InvocationProvider, SceneCodes
{
/**
* Constructs a scene provider that will interact with the supplied
* scene registry.
*/
public SceneProvider (InvocationManager invmgr, SceneRegistry screg)
public SceneProvider (LocationProvider locprov, SceneRegistry screg)
{
_invmgr = invmgr;
_locprov = locprov;
_screg = screg;
}
/**
* Processes a request from a client to move to a new scene.
*/
public void handleMoveToRequest (BodyObject source, int invid,
int sceneId, int sceneVersion)
public void moveTo (ClientObject caller, int sceneId,
final int sceneVer, final SceneMoveListener listener)
{
// avoid cluttering up the method declaration with final keywords
final BodyObject fsource = source;
final int finvid = invid;
final int fsceneVer = sceneVersion;
final BodyObject source = (BodyObject)caller;
// create a callback object that will handle the resolution or
// failed resolution of the scene
@@ -51,7 +49,7 @@ public class SceneProvider extends InvocationProvider
{
public void sceneWasResolved (SceneManager scmgr)
{
finishMoveToRequest(fsource, finvid, scmgr, fsceneVer);
finishMoveToRequest(source, scmgr, sceneVer, listener);
}
public void sceneFailedToResolve (
@@ -60,8 +58,7 @@ 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, MOVE_FAILED_RESPONSE,
NO_SUCH_PLACE);
listener.requestFailed(NO_SUCH_PLACE);
}
};
@@ -74,8 +71,9 @@ public class SceneProvider extends InvocationProvider
* This is called after the scene to which we are moving is guaranteed
* to have been loaded into the server.
*/
protected void finishMoveToRequest (BodyObject source, int invid,
SceneManager scmgr, int sceneVersion)
protected void finishMoveToRequest (
BodyObject source, SceneManager scmgr, int sceneVersion,
SceneMoveListener listener)
{
// move to the place object associated with this scene
PlaceObject plobj = scmgr.getPlaceObject();
@@ -83,23 +81,18 @@ public class SceneProvider extends InvocationProvider
try {
// try doing the actual move
PlaceConfig config = LocationProvider.moveTo(source, ploid);
PlaceConfig config = _locprov.moveTo(source, ploid);
// check to see if they need a newer version of the scene data
SceneModel model = scmgr.getSceneModel();
if (sceneVersion < model.version) {
// then send the moveTo response
sendResponse(source, invid, MOVE_SUCCEEDED_PLUS_UPDATE_RESPONSE,
new Integer(ploid), config, model);
listener.moveSucceededPlusUpdate(ploid, config, model);
} else {
// then send the moveTo response
sendResponse(source, invid, MOVE_SUCCEEDED_RESPONSE,
new Integer(ploid), config);
listener.moveSucceeded(ploid, config);
}
} catch (ServiceFailedException sfe) {
sendResponse(source, invid, MOVE_FAILED_RESPONSE, sfe.getMessage());
} catch (InvocationException sfe) {
listener.requestFailed(sfe.getMessage());
}
}
@@ -108,20 +101,18 @@ public class SceneProvider extends InvocationProvider
* request to move to the specified new scene. This is the
* scene-equivalent to {@link LocationProvider#moveBody}.
*/
public static void moveBody (BodyObject source, int sceneId)
public void moveBody (BodyObject source, int sceneId)
{
// first remove them from their old place
LocationProvider.leaveOccupiedPlace(source);
_locprov.leaveOccupiedPlace(source);
// then send a move notification
_invmgr.sendNotification(
source.getOid(), MODULE_NAME, MOVE_NOTIFICATION,
new Object[] { new Integer(sceneId) });
// then send a forced move notification
SceneSender.forcedMove(source, sceneId);
}
/** The invocation manager with which we interact. */
protected static InvocationManager _invmgr;
/** The location provider we use to handle low-level location stuff. */
protected LocationProvider _locprov;
/** The scene registry with which we interact. */
protected static SceneRegistry _screg;
protected SceneRegistry _screg;
}
@@ -1,5 +1,5 @@
//
// $Id: SceneRegistry.java,v 1.15 2002/05/26 02:24:46 mdb Exp $
// $Id: SceneRegistry.java,v 1.16 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.server;
@@ -37,6 +37,9 @@ import com.threerings.whirled.server.persist.SceneRepository;
*/
public class SceneRegistry
{
/** Used to provide scene-related server-side services. */
public SceneProvider sceneprov;
/**
* Constructs a scene registry, instructing it to load and store
* scenes using the supplied scene repository.
@@ -50,8 +53,8 @@ public class SceneRegistry
_scfact = new DefaultRuntimeSceneFactory();
// create/register a scene provider with the invocation services
SceneProvider provider = new SceneProvider(invmgr, this);
invmgr.registerProvider(SceneProvider.MODULE_NAME, provider);
sceneprov = new SceneProvider(CrowdServer.plreg.locprov, this);
invmgr.registerDispatcher(new SceneDispatcher(sceneprov), true);
}
/**
@@ -0,0 +1,30 @@
//
// $Id: SceneSender.java,v 1.1 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.server;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationSender;
import com.threerings.whirled.client.SceneDecoder;
import com.threerings.whirled.client.SceneReceiver;
/**
* Used to issue notifications to a {@link SceneReceiver} instance on a
* client.
*/
public class SceneSender extends InvocationSender
{
/**
* Issues a notification that will result in a call to {@link
* SceneReceiver#forcedMove} on a client.
*/
public static void forcedMove (
ClientObject target, int arg1)
{
sendNotification(
target, SceneDecoder.RECEIVER_CODE, SceneDecoder.FORCED_MOVE,
new Object[] { new Integer(arg1) });
}
// Generated on 11:25:48 08/12/02.
}
@@ -1,5 +1,5 @@
//
// $Id: SpotSceneDirector.java,v 1.17 2002/07/26 20:35:02 ray Exp $
// $Id: SpotSceneDirector.java,v 1.18 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.spot.client;
@@ -7,6 +7,9 @@ import java.util.Iterator;
import com.samskivert.util.ResultListener;
import com.samskivert.util.StringUtil;
import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.ObjectAccessException;
@@ -31,8 +34,8 @@ import com.threerings.whirled.spot.data.SpotCodes;
* Extends the standard scene director with facilities to move between
* locations within a scene.
*/
public class SpotSceneDirector
implements SpotCodes, Subscriber
public class SpotSceneDirector extends BasicDirector
implements SpotCodes, Subscriber, SpotService.ChangeLocListener
{
/**
* This is used to communicate back to the caller of {@link
@@ -64,6 +67,8 @@ public class SpotSceneDirector
public SpotSceneDirector (WhirledContext ctx, LocationDirector locdir,
SceneDirector scdir)
{
super(ctx);
_ctx = ctx;
_scdir = scdir;
@@ -149,7 +154,7 @@ public class SpotSceneDirector
}
// issue a traversePortal request
SpotService.traversePortal(
_sservice.traversePortal(
_ctx.getClient(), scene.getId(), portalId, sceneVer, _scdir);
return true;
}
@@ -193,9 +198,9 @@ public class SpotSceneDirector
// make a note that we're changing to this location
_pendingLocId = locationId;
_changeObserver = obs;
// and send the location change request
SpotService.changeLoc(_ctx.getClient(), scene.getId(),
locationId, this);
_sservice.changeLoc(_ctx.getClient(), scene.getId(), locationId, this);
}
/**
@@ -243,15 +248,19 @@ public class SpotSceneDirector
}
// we're all clear to go
SpotService.clusterSpeak(
_ctx.getClient(), scene.getId(), _locationId, message, mode, this);
_sservice.clusterSpeak(_ctx.getClient(), scene.getId(), _locationId,
message, mode);
return true;
}
/**
* Called in response to a successful <code>changeLoc</code> request.
*/
public void handleChangeLocSucceeded (int invid, int clusterOid)
// documentation inherited
protected void fetchServices (Client client)
{
_sservice = (SpotService)client.requireService(SpotService.class);
}
// documentation inherited from interface
public void changeLocSucceeded (int clusterOid)
{
ChangeObserver obs = _changeObserver;
_locationId = _pendingLocId;
@@ -285,10 +294,8 @@ public class SpotSceneDirector
}
}
/**
* Called in response to a failed <code>changeLoc</code> request.
*/
public void handleChangeLocFailed (int invid, String reason)
// documentation inherited from interface
public void requestFailed (String reason)
{
ChangeObserver obs = _changeObserver;
int locId = _pendingLocId;
@@ -343,6 +350,9 @@ public class SpotSceneDirector
/** The active client context. */
protected WhirledContext _ctx;
/** Access to spot scene services. */
protected SpotService _sservice;
/** The scene director with which we are cooperating. */
protected SceneDirector _scdir;
@@ -1,69 +1,53 @@
//
// $Id: SpotService.java,v 1.10 2002/07/22 22:54:04 ray Exp $
// $Id: SpotService.java,v 1.11 2002/08/14 19:07:57 mdb Exp $
package com.threerings.whirled.spot.client;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationDirector;
import com.threerings.presents.client.InvocationService;
import com.threerings.whirled.client.SceneDirector;
import com.threerings.whirled.spot.Log;
import com.threerings.whirled.spot.data.SpotCodes;
import com.threerings.whirled.client.SceneService.SceneMoveListener;
/**
* Provides a mechanism by which the client can request to move between
* Defines the mechanism by which the client can request to move between
* locations within a scene and between scenes (taking exit and entry
* locations into account). These services should not be used directly,
* but instead should be accessed via the {@link SpotSceneDirector}.
*/
public class SpotService implements SpotCodes
public interface SpotService extends InvocationService
{
/**
* Requests to traverse the specified portal.
*/
public static void traversePortal (
public void traversePortal (
Client client, int sceneId, int portalId, int sceneVer,
Object rsptarget)
SceneMoveListener listener);
/**
* Used to communicate responses to a {@link #changeLoc} request.
*/
public static interface ChangeLocListener extends InvocationListener
{
InvocationDirector invdir = client.getInvocationDirector();
Object[] args = new Object[] {
new Integer(sceneId), new Integer(portalId),
new Integer(sceneVer) };
invdir.invoke(MODULE_NAME, TRAVERSE_PORTAL_REQUEST, args, rsptarget);
Log.debug("Sent traversePortal request [sceneId=" + sceneId +
", portalId=" + portalId + ", sceneVer=" + sceneVer + "].");
/**
* Called when the change location request succeeded.
*
* @param clusterOid the object id of the cluster object
* associated with the new location.
*/
public void changeLocSucceeded (int clusterOid);
}
/**
* Requests that this client's body be made to occupy the specified
* location.
*/
public static void changeLoc (Client client, int sceneId, int locationId,
Object rsptarget)
{
InvocationDirector invdir = client.getInvocationDirector();
Object[] args = new Object[] { new Integer(sceneId),
new Integer(locationId) };
invdir.invoke(MODULE_NAME, CHANGE_LOC_REQUEST, args, rsptarget);
Log.debug("Sent changeLoc request [sceneId=" + sceneId +
", locId=" + locationId + "].");
}
public void changeLoc (Client client, int sceneId, int locationId,
ChangeLocListener listener);
/**
* Requests that the supplied message be delivered to listeners in the
* cluster to which the specified location belongs.
*/
public static void clusterSpeak (
Client client, int sceneId, int locationId, String message,
byte mode, SpotSceneDirector rsptarget)
{
InvocationDirector invdir = client.getInvocationDirector();
Object[] args = new Object[] {
new Integer(sceneId), new Integer(locationId), message,
new Byte(mode) };
invdir.invoke(MODULE_NAME, CLUSTER_SPEAK_REQUEST, args, rsptarget);
Log.debug("Sent clusterSpeak request [sceneId=" + sceneId +
", locId=" + locationId + ", message=" + message + "].");
}
public void clusterSpeak (Client client, int sceneId, int locationId,
String message, byte mode);
}
@@ -1,5 +1,5 @@
//
// $Id: SpotCodes.java,v 1.2 2002/04/15 18:06:20 mdb Exp $
// $Id: SpotCodes.java,v 1.3 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.spot.data;
@@ -13,39 +13,14 @@ import com.threerings.whirled.spot.client.SpotSceneDirector;
*/
public interface SpotCodes extends ChatCodes, SceneCodes
{
/** The module name for the Spot services. */
public static final String MODULE_NAME = "whirled!spot";
/** The message identifier for a traversePortal request. Such a
* request generates a moveTo response rather than a specialized
* response. */
public static final String TRAVERSE_PORTAL_REQUEST = "TraversePortal";
/** An error code indicating that the portal specified in a
* traversePortal request does not exist. */
public static final String NO_SUCH_PORTAL = "m.no_such_portal";
/** The message identifier for a changeLoc request. */
public static final String CHANGE_LOC_REQUEST = "ChangeLoc";
/** The response identifier for a successful changeLoc request. This
* is mapped by the invocation services to a call to {@link
* SpotSceneDirector#handleChangeLocSucceeded}. */
public static final String CHANGE_LOC_SUCCEEDED_RESPONSE =
"ChangeLocSucceeded";
/** The response identifier for a failed changeLoc request. This is
* mapped by the invocation services to a call to {@link
* SpotSceneDirector#handleChangeLocFailed}. */
public static final String CHANGE_LOC_FAILED_RESPONSE = "ChangeLocFailed";
/** An error code indicating that a location is occupied. Usually
* generated by a failed changeLoc request. */
public static final String LOCATION_OCCUPIED = "m.location_occupied";
/** The message identifier for a cluster speak request. */
public static final String CLUSTER_SPEAK_REQUEST = "ClusterSpeak";
/** The chat type code with which we register our cluster auxiliary
* chat objects. Chat display implementations should interpret chat
* messages with this type accordingly. */
@@ -0,0 +1,93 @@
//
// $Id: SpotMarshaller.java,v 1.1 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.spot.data;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent;
import com.threerings.whirled.client.SceneService.SceneMoveListener;
import com.threerings.whirled.data.SceneMarshaller.SceneMoveMarshaller;
import com.threerings.whirled.spot.client.SpotService;
import com.threerings.whirled.spot.client.SpotService.ChangeLocListener;
/**
* Provides the implementation of the {@link SpotService} interface
* that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back
* to the requesting client.
*/
public class SpotMarshaller extends InvocationMarshaller
implements SpotService
{
// documentation inherited
public static class ChangeLocMarshaller extends ListenerMarshaller
implements ChangeLocListener
{
/** The method id used to dispatch {@link #changeLocSucceeded}
* responses. */
public static final int CHANGE_LOC_SUCCEEDED = 0;
// documentation inherited from interface
public void changeLocSucceeded (int arg1)
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, CHANGE_LOC_SUCCEEDED,
new Object[] { new Integer(arg1) }));
}
// documentation inherited
public void dispatchResponse (int methodId, Object[] args)
{
switch (methodId) {
case CHANGE_LOC_SUCCEEDED:
((ChangeLocListener)listener).changeLocSucceeded(
((Integer)args[0]).intValue());
return;
default:
super.dispatchResponse(methodId, args);
}
}
}
/** The method id used to dispatch {@link #traversePortal} requests. */
public static final int TRAVERSE_PORTAL = 1;
// documentation inherited from interface
public void traversePortal (Client arg1, int arg2, int arg3, int arg4, SceneMoveListener arg5)
{
SceneMoveMarshaller listener5 = new SceneMoveMarshaller();
listener5.listener = arg5;
sendRequest(arg1, TRAVERSE_PORTAL, new Object[] {
new Integer(arg2), new Integer(arg3), new Integer(arg4), listener5
});
}
/** The method id used to dispatch {@link #changeLoc} requests. */
public static final int CHANGE_LOC = 2;
// documentation inherited from interface
public void changeLoc (Client arg1, int arg2, int arg3, ChangeLocListener arg4)
{
ChangeLocMarshaller listener4 = new ChangeLocMarshaller();
listener4.listener = arg4;
sendRequest(arg1, CHANGE_LOC, new Object[] {
new Integer(arg2), new Integer(arg3), listener4
});
}
/** The method id used to dispatch {@link #clusterSpeak} requests. */
public static final int CLUSTER_SPEAK = 3;
// documentation inherited from interface
public void clusterSpeak (Client arg1, int arg2, int arg3, String arg4, byte arg5)
{
sendRequest(arg1, CLUSTER_SPEAK, new Object[] {
new Integer(arg2), new Integer(arg3), arg4, new Byte(arg5)
});
}
// Class file generated on 00:26:02 08/11/02.
}
@@ -0,0 +1,68 @@
//
// $Id: SpotDispatcher.java,v 1.1 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.spot.server;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.server.InvocationDispatcher;
import com.threerings.presents.server.InvocationException;
import com.threerings.whirled.client.SceneService.SceneMoveListener;
import com.threerings.whirled.data.SceneMarshaller.SceneMoveMarshaller;
import com.threerings.whirled.spot.client.SpotService;
import com.threerings.whirled.spot.client.SpotService.ChangeLocListener;
import com.threerings.whirled.spot.data.SpotMarshaller;
/**
* Dispatches requests to the {@link SpotProvider}.
*/
public class SpotDispatcher extends InvocationDispatcher
{
/**
* Creates a dispatcher that may be registered to dispatch invocation
* service requests for the specified provider.
*/
public SpotDispatcher (SpotProvider provider)
{
this.provider = provider;
}
// documentation inherited
public InvocationMarshaller createMarshaller ()
{
return new SpotMarshaller();
}
// documentation inherited
public void dispatchRequest (
ClientObject source, int methodId, Object[] args)
throws InvocationException
{
switch (methodId) {
case SpotMarshaller.TRAVERSE_PORTAL:
((SpotProvider)provider).traversePortal(
source,
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), ((Integer)args[2]).intValue(), (SceneMoveListener)args[3]
);
return;
case SpotMarshaller.CHANGE_LOC:
((SpotProvider)provider).changeLoc(
source,
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), (ChangeLocListener)args[2]
);
return;
case SpotMarshaller.CLUSTER_SPEAK:
((SpotProvider)provider).clusterSpeak(
source,
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), (String)args[2], ((Byte)args[3]).byteValue()
);
return;
default:
super.dispatchRequest(source, methodId, args);
}
}
}
@@ -1,123 +1,117 @@
//
// $Id: SpotProvider.java,v 1.12 2002/07/22 22:54:04 ray Exp $
// $Id: SpotProvider.java,v 1.13 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.spot.server;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.presents.server.ServiceFailedException;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.LocationProvider;
import com.threerings.crowd.server.PlaceRegistry;
import com.threerings.whirled.client.SceneService.SceneMoveListener;
import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.server.SceneManager;
import com.threerings.whirled.server.SceneRegistry;
import com.threerings.whirled.spot.Log;
import com.threerings.whirled.spot.client.SpotService.ChangeLocListener;
import com.threerings.whirled.spot.data.SpotCodes;
import com.threerings.whirled.spot.data.SpotOccupantInfo;
/**
* This class provides the server side of the spot services.
* Provides the server-side implementation of the spot services.
*/
public class SpotProvider extends InvocationProvider
implements SpotCodes
public class SpotProvider
implements SpotCodes, InvocationProvider
{
/**
* Constructs a spot provider and registers it with the invocation
* manager to handle spot services. This need be done by a server that
* wishes to make use of the Spot services.
* Creates a spot provider that can be registered with the invocation
* manager to handle spot services.
*/
public static void init (
InvocationManager invmgr, SceneRegistry screg, RootDObjectManager omgr)
public SpotProvider (RootDObjectManager omgr, PlaceRegistry plreg,
SceneRegistry screg)
{
// we'll need these later
_plreg = plreg;
_screg = screg;
_omgr = omgr;
// register a spot provider instance
invmgr.registerProvider(MODULE_NAME, new SpotProvider());
}
/**
* Processes a request from a client to traverse a portal.
*
* @param source the body object of the client making the request.
* @param invid the invocation service invocation id.
* @param sceneId the source scene id.
* @param portalId the portal in the source scene that is being
* traversed.
* @param sceneVer the version of the destination scene data that the
* client has cached.
* @param listener the entity to which we communicate our response.
*/
public void handleTraversePortalRequest (
BodyObject source, int invid, int sceneId, int portalId, int sceneVer)
public void traversePortal (ClientObject caller, int sceneId, int portalId,
int sceneVer, SceneMoveListener listener)
throws InvocationException
{
try {
// obtain the source scene
SpotSceneManager smgr = (SpotSceneManager)
_screg.getSceneManager(sceneId);
if (smgr == null) {
Log.warning("Traverse portal missing source scene " +
"[user=" + source.who() + ", sceneId=" + sceneId +
", portalId=" + portalId + "].");
throw new ServiceFailedException(INTERNAL_ERROR);
}
// avoid cluttering up the method declaration with final keywords
final BodyObject fsource = (BodyObject)caller;
final int fportalId = portalId;
final int fsceneVer = sceneVer;
final SceneMoveListener flistener = listener;
// obtain the destination scene and location id
RuntimeSpotScene rss = (RuntimeSpotScene)smgr.getScene();
int destSceneId = rss.getTargetSceneId(portalId);
final int destLocId = rss.getTargetLocationId(portalId);
// make sure this portal has valid info
if (destSceneId == -1) {
Log.warning("Traverse portal provided with invalid portal " +
"[user=" + source.who() + ", sceneId=" + sceneId +
", portalId=" + portalId +
", destSceneId=" + destSceneId + "].");
throw new ServiceFailedException(NO_SUCH_PORTAL);
}
// avoid cluttering up the method declaration with final
// keywords
final BodyObject fsource = source;
final int finvid = invid;
final int fportalId = portalId;
final int fsceneVer = sceneVer;
// create a callback object that will handle the resolution or
// failed resolution of the scene
SceneRegistry.ResolutionListener rl =
new SceneRegistry.ResolutionListener() {
public void sceneWasResolved (SceneManager scmgr) {
SpotSceneManager sscmgr = (SpotSceneManager)scmgr;
finishTraversePortalRequest(
fsource, finvid, sscmgr, fsceneVer,
fportalId, destLocId);
}
public void sceneFailedToResolve (
int rsceneId, Exception reason) {
Log.warning("Unable to resolve target scene " +
"[sceneId=" + rsceneId +
", reason=" + reason + "].");
// pretend like the scene doesn't exist to the client
sendResponse(fsource, finvid, MOVE_FAILED_RESPONSE,
NO_SUCH_PLACE);
}
};
// make sure the scene they are headed to is actually loaded into
// the server
_screg.resolveScene(destSceneId, rl);
} catch (ServiceFailedException sfe) {
sendResponse(source, invid, MOVE_FAILED_RESPONSE, sfe.getMessage());
// obtain the source scene
SpotSceneManager smgr = (SpotSceneManager)
_screg.getSceneManager(sceneId);
if (smgr == null) {
Log.warning("Traverse portal missing source scene " +
"[user=" + fsource.who() + ", sceneId=" + sceneId +
", portalId=" + portalId + "].");
throw new InvocationException(INTERNAL_ERROR);
}
// obtain the destination scene and location id
RuntimeSpotScene rss = (RuntimeSpotScene)smgr.getScene();
int destSceneId = rss.getTargetSceneId(portalId);
final int destLocId = rss.getTargetLocationId(portalId);
// make sure this portal has valid info
if (destSceneId == -1) {
Log.warning("Traverse portal provided with invalid portal " +
"[user=" + fsource.who() + ", sceneId=" + sceneId +
", portalId=" + portalId +
", destSceneId=" + destSceneId + "].");
throw new InvocationException(NO_SUCH_PORTAL);
}
// create a callback object that will handle the resolution or
// failed resolution of the scene
SceneRegistry.ResolutionListener rl =
new SceneRegistry.ResolutionListener() {
public void sceneWasResolved (SceneManager scmgr) {
SpotSceneManager sscmgr = (SpotSceneManager)scmgr;
finishTraversePortalRequest(
fsource, sscmgr, fsceneVer, fportalId, destLocId,
flistener);
}
public void sceneFailedToResolve (
int rsceneId, Exception reason) {
Log.warning("Unable to resolve target scene " +
"[sceneId=" + rsceneId +
", reason=" + reason + "].");
// pretend like the scene doesn't exist to the client
flistener.requestFailed(NO_SUCH_PLACE);
}
};
// make sure the scene they are headed to is actually loaded into
// the server
_screg.resolveScene(destSceneId, rl);
}
/**
@@ -125,8 +119,8 @@ public class SpotProvider extends InvocationProvider
* to have been loaded into the server.
*/
protected void finishTraversePortalRequest (
BodyObject source, int invid, SpotSceneManager scmgr,
int sceneVer, int exitPortalId, int destLocId)
BodyObject source, SpotSceneManager scmgr, int sceneVer,
int exitPortalId, int destLocId, SceneMoveListener listener)
{
// move to the place object associated with this scene
PlaceObject plobj = scmgr.getPlaceObject();
@@ -138,23 +132,21 @@ public class SpotProvider extends InvocationProvider
try {
// try doing the actual move
PlaceConfig config = LocationProvider.moveTo(source, ploid);
PlaceConfig config = _plreg.locprov.moveTo(source, ploid);
// check to see if they need a newer version of the scene data
SceneModel model = scmgr.getSceneModel();
if (sceneVer < model.version) {
// then send the moveTo response
sendResponse(source, invid, MOVE_SUCCEEDED_PLUS_UPDATE_RESPONSE,
new Integer(ploid), config, model);
listener.moveSucceededPlusUpdate(ploid, config, model);
} else {
// then send the moveTo response
sendResponse(source, invid, MOVE_SUCCEEDED_RESPONSE,
new Integer(ploid), config);
listener.moveSucceeded(ploid, config);
}
} catch (ServiceFailedException sfe) {
sendResponse(source, invid, MOVE_FAILED_RESPONSE, sfe.getMessage());
} catch (InvocationException sfe) {
listener.requestFailed(sfe.getMessage());
// and let the destination scene manager know that we're no
// longer coming in
@@ -165,39 +157,35 @@ public class SpotProvider extends InvocationProvider
/**
* Processes a request from a client to move to a new location.
*/
public void handleChangeLocRequest (
BodyObject source, int invid, int sceneId, int locationId)
public void changeLoc (ClientObject caller, int sceneId, int locationId,
ChangeLocListener listener)
throws InvocationException
{
try {
// look up the scene manager for the specified scene
SpotSceneManager smgr = (SpotSceneManager)
_screg.getSceneManager(sceneId);
if (smgr == null) {
Log.warning("User requested to change location in " +
"non-existent scene [user=" + source.who() +
", sceneId=" + sceneId +
", locId=" + locationId + "].");
throw new ServiceFailedException(INTERNAL_ERROR);
}
BodyObject source = (BodyObject)caller;
int locOid = smgr.handleChangeLocRequest(source, locationId);
sendResponse(source, invid, CHANGE_LOC_SUCCEEDED_RESPONSE,
new Integer(locOid));
} catch (ServiceFailedException sfe) {
sendResponse(source, invid, CHANGE_LOC_FAILED_RESPONSE,
sfe.getMessage());
// look up the scene manager for the specified scene
SpotSceneManager smgr = (SpotSceneManager)
_screg.getSceneManager(sceneId);
if (smgr == null) {
Log.warning("User requested to change location in " +
"non-existent scene [user=" + source.who() +
", sceneId=" + sceneId +
", locId=" + locationId + "].");
throw new InvocationException(INTERNAL_ERROR);
}
int locOid = smgr.handleChangeLocRequest(source, locationId);
listener.changeLocSucceeded(locOid);
}
/**
* Handles {@link SpotCodes#CLUSTER_SPEAK_REQUEST} messages.
* Handles request to generate a speak message in the specified cluster.
*/
public void handleClusterSpeakRequest (
BodyObject source, int invid, int sceneId, int locId, String message,
byte mode)
public void clusterSpeak (ClientObject caller, int sceneId, int locationId,
String message, byte mode)
{
sendClusterChatMessage(sceneId, locId, source.getOid(),
BodyObject source = (BodyObject)caller;
sendClusterChatMessage(sceneId, locationId, source.getOid(),
source.username, null, message, mode);
}
@@ -220,7 +208,7 @@ public class SpotProvider extends InvocationProvider
* from a real live human who wrote it in their native tongue).
* @param message the text of the chat message.
*/
public static void sendClusterChatMessage (
public void sendClusterChatMessage (
int sceneId, int locId, int speakerOid, String speaker,
String bundle, String message, byte mode)
{
@@ -242,9 +230,12 @@ public class SpotProvider extends InvocationProvider
}
}
/** The place registry with which we interoperate. */
protected PlaceRegistry _plreg;
/** The scene registry with which we interoperate. */
protected static SceneRegistry _screg;
protected SceneRegistry _screg;
/** The object manager we use to do dobject stuff. */
protected static RootDObjectManager _omgr;
protected RootDObjectManager _omgr;
}
@@ -1,5 +1,5 @@
//
// $Id: SpotSceneManager.java,v 1.15 2002/07/22 22:54:04 ray Exp $
// $Id: SpotSceneManager.java,v 1.16 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.spot.server;
@@ -10,9 +10,9 @@ import com.samskivert.util.StringUtil;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.dobj.ObjectAccessException;
import com.threerings.presents.server.ServiceFailedException;
import com.threerings.presents.server.InvocationException;
import com.threerings.crowd.chat.ChatProvider;
import com.threerings.crowd.chat.SpeakProvider;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.whirled.server.SceneManager;
@@ -82,13 +82,13 @@ public class SpotSceneManager extends SceneManager
// now that we have our scene, we create chat objects for each of
// the clusters in the scene
_clusterOids = new int[_sscene.getClusterCount()];
_clusterObjs = new DObject[_sscene.getClusterCount()];
// create a subscriber that will grab the oids when we hear back
// about object creation
Subscriber sub = new Subscriber() {
public void objectAvailable (DObject object) {
_clusterOids[_index++] = object.getOid();
_clusterObjs[_index++] = object;
}
public void requestFailed (int oid, ObjectAccessException cause) {
@@ -103,7 +103,7 @@ public class SpotSceneManager extends SceneManager
};
// now issue the object creation requests
for (int i = 0; i < _clusterOids.length; i++) {
for (int i = 0; i < _clusterObjs.length; i++) {
_omgr.createObject(DObject.class, sub);
}
@@ -148,12 +148,12 @@ public class SpotSceneManager extends SceneManager
* which this location belongs or -1 if the location is not part of a
* cluster.
*
* @exception ServiceFailedException thrown with a reason code
* explaining the location change failure if there is a problem
* processing the location change request.
* @exception InvocationException thrown with a reason code explaining
* the location change failure if there is a problem processing the
* location change request.
*/
protected int handleChangeLocRequest (BodyObject source, int locationId)
throws ServiceFailedException
throws InvocationException
{
// make sure no one is already in the requested location
int locidx = _sscene.getLocationIndex(locationId);
@@ -161,14 +161,14 @@ public class SpotSceneManager extends SceneManager
Log.warning("Ignoring request to move to non-existent location " +
"[where=" + where() + ", user=" + source.who() +
", locId=" + locationId + "].");
throw new ServiceFailedException(LOCATION_OCCUPIED);
throw new InvocationException(LOCATION_OCCUPIED);
} else if (_locationOccs[locidx] > 0) {
Log.info("Ignoring request to move to occupied location " +
"[where=" + where() + ", user=" + source.who() +
", locId=" + locationId +
", occupantOid=" + _locationOccs[locidx] + "].");
throw new ServiceFailedException(LOCATION_OCCUPIED);
throw new InvocationException(LOCATION_OCCUPIED);
}
// make sure they have an occupant info object in the place
@@ -179,7 +179,7 @@ public class SpotSceneManager extends SceneManager
Log.warning("Aiya! Can't update non-existent occupant info " +
"with new location [where=" + where() +
", body=" + source.who() + "].");
throw new ServiceFailedException(INTERNAL_ERROR);
throw new InvocationException(INTERNAL_ERROR);
}
// clear out any location they previously occupied
@@ -209,7 +209,7 @@ public class SpotSceneManager extends SceneManager
// figure out the cluster chat oid
int clusterIdx = _sscene.getClusterIndex(locidx);
return (clusterIdx == -1) ? -1 : _clusterOids[clusterIdx];
return (clusterIdx == -1) ? -1 : _clusterObjs[clusterIdx].getOid();
}
/**
@@ -241,10 +241,9 @@ public class SpotSceneManager extends SceneManager
}
// all is well, generate a chat notification
int clusterOid = _clusterOids[clusterIndex];
if (clusterOid > 0) {
ChatProvider.sendChatMessage(
clusterOid, source, bundle, message, mode);
DObject clusterObj = _clusterObjs[clusterIndex];
if (clusterObj != null) {
SpeakProvider.sendSpeak(clusterObj, source, bundle, message, mode);
} else {
Log.warning("Have no cluster object for CCREQ " +
@@ -297,8 +296,8 @@ public class SpotSceneManager extends SceneManager
/** A casted reference to our runtime scene instance. */
protected RuntimeSpotScene _sscene;
/** Oids of the cluster chat objects. */
protected int[] _clusterOids;
/** Our cluster chat objects. */
protected DObject[] _clusterObjs;
/** Oids of the bodies that occupy each of our locations. */
protected int[] _locationOccs;
@@ -0,0 +1,52 @@
//
// $Id: ZoneDecoder.java,v 1.1 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.client;
import com.threerings.presents.client.InvocationDecoder;
import com.threerings.whirled.zone.client.ZoneReceiver;
/**
* Dispatches calls to a {@link ZoneReceiver} instance.
*/
public class ZoneDecoder extends InvocationDecoder
{
/** The generated hash code used to identify this receiver class. */
public static final String RECEIVER_CODE = "2d900cf54355111b4bb4befcdff42b82";
/** The method id used to dispatch {@link ZoneReceiver#forcedMove}
* notifications. */
public static final int FORCED_MOVE = 1;
/**
* Creates a decoder that may be registered to dispatch invocation
* service notifications to the specified receiver.
*/
public ZoneDecoder (ZoneReceiver receiver)
{
this.receiver = receiver;
}
// documentation inherited
public String getReceiverCode ()
{
return RECEIVER_CODE;
}
// documentation inherited
public void dispatchNotification (int methodId, Object[] args)
{
switch (methodId) {
case FORCED_MOVE:
((ZoneReceiver)receiver).forcedMove(
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue()
);
return;
default:
super.dispatchNotification(methodId, args);
}
}
// Generated on 11:25:47 08/12/02.
}
@@ -1,5 +1,5 @@
//
// $Id: ZoneDirector.java,v 1.8 2002/06/14 01:40:16 ray Exp $
// $Id: ZoneDirector.java,v 1.9 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.client;
@@ -7,7 +7,9 @@ import java.util.ArrayList;
import com.samskivert.util.ResultListener;
import com.threerings.presents.client.InvocationReceiver;
import com.threerings.presents.client.BasicDirector;
import com.threerings.presents.client.Client;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.whirled.client.SceneDirector;
@@ -15,7 +17,6 @@ import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.util.WhirledContext;
import com.threerings.whirled.zone.Log;
import com.threerings.whirled.zone.data.ZoneCodes;
import com.threerings.whirled.zone.data.ZoneSummary;
/**
@@ -27,8 +28,8 @@ import com.threerings.whirled.zone.data.ZoneSummary;
* summary which provides information on the zone which can be used to
* generate an overview map or similar.
*/
public class ZoneDirector
implements InvocationReceiver, ZoneCodes
public class ZoneDirector extends BasicDirector
implements ZoneReceiver, ZoneService.ZoneMoveListener
{
/**
* Constructs a zone director with the supplied context, and delegate
@@ -38,12 +39,13 @@ public class ZoneDirector
*/
public ZoneDirector (WhirledContext ctx, SceneDirector scdir)
{
super(ctx);
_ctx = ctx;
_scdir = scdir;
// register for zone notifications
_ctx.getClient().getInvocationDirector().registerReceiver(
MODULE_NAME, this);
new ZoneDecoder(this));
}
/**
@@ -116,41 +118,46 @@ public class ZoneDirector
}
// issue a moveTo request
ZoneService.moveTo(_ctx.getClient(), zoneId, sceneId, sceneVers, this);
_zservice.moveTo(_ctx.getClient(), zoneId, sceneId, sceneVers, this);
return true;
}
// documentation inherited
protected void fetchServices (Client client)
{
_zservice = (ZoneService)client.requireService(ZoneService.class);
}
/**
* Called in response to a successful zoned <code>moveTo</code>
* Called in response to a successful {@link ZoneService#moveTo}
* request.
*/
public void handleMoveSucceeded (
int invid, int placeId, PlaceConfig config, ZoneSummary summary)
public void moveSucceeded (
int placeId, PlaceConfig config, ZoneSummary summary)
{
// keep track of the summary
_summary = summary;
// pass the rest off to the standard scene transition code
_scdir.handleMoveSucceeded(invid, placeId, config);
_scdir.moveSucceeded(placeId, config);
// and let the zone observers know what's up
notifyObservers(summary);
}
/**
* Called in response to a successful zoned <code>moveTo</code>
* Called in response to a successful {@link ZoneService#moveTo}
* request when our cached scene was out of date and the server
* determined that we needed an updated copy.
*/
public void handleMoveSucceededPlusUpdate (
int invid, int placeId, PlaceConfig config, ZoneSummary summary,
SceneModel model)
public void moveSucceededPlusUpdate (
int placeId, PlaceConfig config, ZoneSummary summary, SceneModel model)
{
// keep track of the summary
_summary = summary;
// pass the rest off to the standard scene transition code
_scdir.handleMoveSucceededPlusUpdate(invid, placeId, config, model);
_scdir.moveSucceededPlusUpdate(placeId, config, model);
// and let the zone observers know what's up
notifyObservers(summary);
@@ -159,22 +166,17 @@ public class ZoneDirector
/**
* Called in response to a failed zoned <code>moveTo</code> request.
*/
public void handleMoveFailed (int invid, String reason)
public void requestFailed (String reason)
{
// let the scene director cope
_scdir.handleMoveFailed(invid, reason);
_scdir.requestFailed(reason);
// and let the observers know what's up
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)
// documentation inherited from interface
public void forcedMove (int zoneId, int sceneId)
{
Log.info("Moving at request of server [zoneId=" + zoneId +
", sceneId=" + sceneId + "].");
@@ -218,6 +220,9 @@ public class ZoneDirector
/** A reference to the scene director with which we coordinate. */
protected SceneDirector _scdir;
/** Provides access to zone services. */
protected ZoneService _zservice;
/** A reference to the zone summary for the currently occupied
* zone. */
protected ZoneSummary _summary;
@@ -0,0 +1,22 @@
//
// $Id: ZoneReceiver.java,v 1.1 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.client;
import com.threerings.presents.client.InvocationReceiver;
/**
* Defines, for the zone services, a set of notifications delivered
* asynchronously by the server to the client.
*/
public interface ZoneReceiver extends InvocationReceiver
{
/**
* Used to communicate a required move notification to the client. The
* server will have removed the client from their existing scene and
* the client is then responsible for generating a {@link
* ZoneService#moveTo} request to move to the new scene in the
* specified zone.
*/
public void forcedMove (int zoneId, int sceneId);
}
@@ -1,20 +1,32 @@
//
// $Id: ZoneService.java,v 1.5 2002/05/15 23:54:35 mdb Exp $
// $Id: ZoneService.java,v 1.6 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.client;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationDirector;
import com.threerings.presents.client.InvocationService;
import com.threerings.whirled.zone.Log;
import com.threerings.whirled.zone.data.ZoneCodes;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.zone.data.ZoneSummary;
/**
* The zone service class provides the client interface to the zone
* related invocation services (e.g. moving between zones).
* Defines the client interface to the zone related invocation services
* (e.g. moving between zones).
*/
public class ZoneService implements ZoneCodes
public interface ZoneService extends InvocationService
{
public static interface ZoneMoveListener extends InvocationListener
{
public void moveSucceeded (
int placeId, PlaceConfig config, ZoneSummary summary);
public void moveSucceededPlusUpdate (
int placeId, PlaceConfig config, ZoneSummary summary,
SceneModel model);
}
/**
* Requests that that this client's body be moved to the specified
* scene in the specified zone.
@@ -23,17 +35,9 @@ public class ZoneService implements ZoneCodes
* @param sceneId the scene id to which we want to move.
* @param sceneVers the version number of the scene object that we
* have in our local repository.
* @param rsptarget the object that will receive the callback when the
* @param listener the object that will receive the callback when the
* request succeeds or fails.
*/
public static void moveTo (Client client, int zoneId, int sceneId,
int sceneVers, Object rsptarget)
{
InvocationDirector invdir = client.getInvocationDirector();
Object[] args = new Object[] {
new Integer(zoneId), new Integer(sceneId), new Integer(sceneVers) };
invdir.invoke(MODULE_NAME, MOVE_TO_REQUEST, args, rsptarget);
Log.debug("Sent moveTo request [zone=" + zoneId +
", scene=" + sceneId + ", version=" + sceneVers + "].");
}
public void moveTo (Client client, int zoneId, int sceneId,
int sceneVers, ZoneMoveListener listener);
}
@@ -1,5 +1,5 @@
//
// $Id: ZoneCodes.java,v 1.1 2002/04/15 16:28:04 shaper Exp $
// $Id: ZoneCodes.java,v 1.2 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.data;
@@ -10,9 +10,6 @@ import com.threerings.whirled.data.SceneCodes;
*/
public interface ZoneCodes extends SceneCodes
{
/** The module name for the zone services. */
public static final String MODULE_NAME = "whirled!zone";
/** An error code indicating that a zone identified by a particular
* zone id does not exist. Usually generated by a failed moveTo
* request. */
@@ -0,0 +1,86 @@
//
// $Id: ZoneMarshaller.java,v 1.1 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.data;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent;
import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.zone.client.ZoneService;
import com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener;
import com.threerings.whirled.zone.data.ZoneSummary;
/**
* Provides the implementation of the {@link ZoneService} interface
* that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back
* to the requesting client.
*/
public class ZoneMarshaller extends InvocationMarshaller
implements ZoneService
{
// documentation inherited
public static class ZoneMoveMarshaller extends ListenerMarshaller
implements ZoneMoveListener
{
/** The method id used to dispatch {@link #moveSucceeded}
* responses. */
public static final int MOVE_SUCCEEDED = 0;
// documentation inherited from interface
public void moveSucceeded (int arg1, PlaceConfig arg2, ZoneSummary arg3)
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, MOVE_SUCCEEDED,
new Object[] { new Integer(arg1), arg2, arg3 }));
}
/** The method id used to dispatch {@link #moveSucceededPlusUpdate}
* responses. */
public static final int MOVE_SUCCEEDED_PLUS_UPDATE = 1;
// documentation inherited from interface
public void moveSucceededPlusUpdate (int arg1, PlaceConfig arg2, ZoneSummary arg3, SceneModel arg4)
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, MOVE_SUCCEEDED_PLUS_UPDATE,
new Object[] { new Integer(arg1), arg2, arg3, arg4 }));
}
// documentation inherited
public void dispatchResponse (int methodId, Object[] args)
{
switch (methodId) {
case MOVE_SUCCEEDED:
((ZoneMoveListener)listener).moveSucceeded(
((Integer)args[0]).intValue(), (PlaceConfig)args[1], (ZoneSummary)args[2]);
return;
case MOVE_SUCCEEDED_PLUS_UPDATE:
((ZoneMoveListener)listener).moveSucceededPlusUpdate(
((Integer)args[0]).intValue(), (PlaceConfig)args[1], (ZoneSummary)args[2], (SceneModel)args[3]);
return;
default:
super.dispatchResponse(methodId, args);
}
}
}
/** The method id used to dispatch {@link #moveTo} requests. */
public static final int MOVE_TO = 1;
// documentation inherited from interface
public void moveTo (Client arg1, int arg2, int arg3, int arg4, ZoneMoveListener arg5)
{
ZoneMoveMarshaller listener5 = new ZoneMoveMarshaller();
listener5.listener = arg5;
sendRequest(arg1, MOVE_TO, new Object[] {
new Integer(arg2), new Integer(arg3), new Integer(arg4), listener5
});
}
// Class file generated on 00:26:02 08/11/02.
}
@@ -0,0 +1,55 @@
//
// $Id: ZoneDispatcher.java,v 1.1 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.server;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.presents.client.Client;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.server.InvocationDispatcher;
import com.threerings.presents.server.InvocationException;
import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.zone.client.ZoneService;
import com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener;
import com.threerings.whirled.zone.data.ZoneMarshaller;
import com.threerings.whirled.zone.data.ZoneSummary;
/**
* Dispatches requests to the {@link ZoneProvider}.
*/
public class ZoneDispatcher extends InvocationDispatcher
{
/**
* Creates a dispatcher that may be registered to dispatch invocation
* service requests for the specified provider.
*/
public ZoneDispatcher (ZoneProvider provider)
{
this.provider = provider;
}
// documentation inherited
public InvocationMarshaller createMarshaller ()
{
return new ZoneMarshaller();
}
// documentation inherited
public void dispatchRequest (
ClientObject source, int methodId, Object[] args)
throws InvocationException
{
switch (methodId) {
case ZoneMarshaller.MOVE_TO:
((ZoneProvider)provider).moveTo(
source,
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), ((Integer)args[2]).intValue(), (ZoneMoveListener)args[3]
);
return;
default:
super.dispatchRequest(source, methodId, args);
}
}
}
@@ -1,11 +1,11 @@
//
// $Id: ZoneProvider.java,v 1.9 2002/05/26 02:29:13 mdb Exp $
// $Id: ZoneProvider.java,v 1.10 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.server;
import com.threerings.presents.server.InvocationManager;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.InvocationProvider;
import com.threerings.presents.server.ServiceFailedException;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig;
@@ -17,6 +17,7 @@ import com.threerings.whirled.server.SceneRegistry;
import com.threerings.whirled.server.SceneManager;
import com.threerings.whirled.zone.Log;
import com.threerings.whirled.zone.client.ZoneService.ZoneMoveListener;
import com.threerings.whirled.zone.data.ZoneCodes;
import com.threerings.whirled.zone.data.ZoneSummary;
import com.threerings.whirled.zone.data.ZonedBodyObject;
@@ -26,7 +27,7 @@ import com.threerings.whirled.zone.data.ZonedBodyObject;
* from zone to zone.
*/
public class ZoneProvider
extends InvocationProvider implements ZoneCodes
implements ZoneCodes, InvocationProvider
{
/**
* Constructs a zone provider that will interoperate with the supplied
@@ -34,10 +35,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 (
InvocationManager invmgr, ZoneRegistry zonereg, SceneRegistry screg)
public ZoneProvider (LocationProvider locprov, ZoneRegistry zonereg,
SceneRegistry screg)
{
_invmgr = invmgr;
_locprov = locprov;
_zonereg = zonereg;
_screg = screg;
}
@@ -45,45 +46,45 @@ public class ZoneProvider
/**
* Processes a request from a client to move to a scene in a new zone.
*
* @param source the user requesting the move.
* @param caller the user requesting the move.
* @param invid the invocation id of the request.
* @param zoneId the qualified zone id of the new zone.
* @param sceneId the identifier of the new scene.
* @param sceneVew the version of the scene model currently held by
* @param sceneVer the version of the scene model currently held by
* the client.
* @param listener the entity to inform of success or failure.
*/
public void handleMoveToRequest (BodyObject source, int invid,
int zoneId, int sceneId, int sceneVer)
public void moveTo (ClientObject caller, int zoneId, int sceneId,
int sceneVer, ZoneMoveListener listener)
throws InvocationException
{
// avoid cluttering up the method declaration with final keywords
final BodyObject fsource = (BodyObject)caller;
final int fsceneId = sceneId;
final int fsceneVer = sceneVer;
final ZoneMoveListener flistener = listener;
// look up the zone manager for the zone
ZoneManager zmgr = _zonereg.getZoneManager(zoneId);
if (zmgr == null) {
Log.warning("Requested to enter a zone for which we have no " +
"manager [user=" + source +
"manager [user=" + fsource.who() +
", zoneId=" + zoneId + "].");
sendResponse(source, invid, MOVE_FAILED_RESPONSE, NO_SUCH_ZONE);
return;
throw new InvocationException(NO_SUCH_ZONE);
}
// avoid cluttering up the method declaration with final keywords
final BodyObject fsource = source;
final int finvid = invid;
final int fsceneId = sceneId;
final int fsceneVer = sceneVer;
// resolve the zone!
ZoneManager.ResolutionListener zl = new ZoneManager.ResolutionListener()
{
public void zoneWasResolved (ZoneSummary summary) {
continueMoveToRequest(fsource, finvid, summary,
fsceneId, fsceneVer);
continueMoveTo(
fsource, summary, fsceneId, fsceneVer, flistener);
}
public void zoneFailedToResolve (int zoneId, Exception reason) {
Log.warning("Unable to resolve zone [zoneId=" + zoneId +
", reason=" + reason + "].");
sendResponse(fsource, finvid,
MOVE_FAILED_RESPONSE, NO_SUCH_ZONE);
flistener.requestFailed(NO_SUCH_ZONE);
}
};
zmgr.resolveZone(zoneId, zl);
@@ -92,21 +93,21 @@ public class ZoneProvider
/**
* This is called after we have resolved our zone.
*/
protected void continueMoveToRequest (
BodyObject source, int invid, ZoneSummary summary,
int sceneId, int sceneVer)
protected void continueMoveTo (
BodyObject source, ZoneSummary summary, int sceneId, int sceneVer,
ZoneMoveListener listener)
{
// avoid cluttering up the method declaration with final keywords
final BodyObject fsource = source;
final int finvid = invid;
final ZoneSummary fsum = summary;
final int fsceneVer = sceneVer;
final ZoneMoveListener flistener = listener;
// give the zone manager a chance to veto the request
ZoneManager zmgr = _zonereg.getZoneManager(summary.zoneId);
String errmsg = zmgr.ratifyBodyEntry(source, summary.zoneId);
if (errmsg != null) {
sendResponse(fsource, finvid, MOVE_FAILED_RESPONSE, errmsg);
listener.requestFailed(errmsg);
return;
}
@@ -116,15 +117,14 @@ public class ZoneProvider
new SceneRegistry.ResolutionListener()
{
public void sceneWasResolved (SceneManager scmgr) {
finishMoveToRequest(fsource, finvid, fsum, scmgr, fsceneVer);
finishMoveTo(fsource, fsum, scmgr, fsceneVer, flistener);
}
public void sceneFailedToResolve (int sceneId, Exception reason) {
Log.warning("Unable to resolve scene [sceneid=" + sceneId +
", reason=" + reason + "].");
// pretend like the scene doesn't exist to the client
sendResponse(fsource, finvid,
MOVE_FAILED_RESPONSE, NO_SUCH_PLACE);
flistener.requestFailed(NO_SUCH_PLACE);
}
};
@@ -137,9 +137,9 @@ public class ZoneProvider
* This is called after the scene to which we are moving is guaranteed
* to have been loaded into the server.
*/
protected void finishMoveToRequest (
BodyObject source, int invid, ZoneSummary summary,
SceneManager scmgr, int sceneVersion)
protected void finishMoveTo (
BodyObject source, ZoneSummary summary, SceneManager scmgr,
int sceneVersion, ZoneMoveListener listener)
{
// move to the place object associated with this scene
PlaceObject plobj = scmgr.getPlaceObject();
@@ -147,7 +147,7 @@ public class ZoneProvider
try {
// try doing the actual move
PlaceConfig config = LocationProvider.moveTo(source, ploid);
PlaceConfig config = _locprov.moveTo(source, ploid);
// now that we've finally moved, we can update the user object
// with the new zone id
@@ -157,23 +157,19 @@ public class ZoneProvider
SceneModel model = scmgr.getSceneModel();
if (sceneVersion < model.version) {
// then send the moveTo response
sendResponse(source, invid, MOVE_SUCCEEDED_PLUS_UPDATE_RESPONSE,
new Object[] { new Integer(ploid), config,
summary, model });
listener.moveSucceededPlusUpdate(ploid, config, summary, model);
} else {
// then send the moveTo response
sendResponse(source, invid, MOVE_SUCCEEDED_RESPONSE,
new Integer(ploid), config, summary);
listener.moveSucceeded(ploid, config, summary);
}
// let the zone manager know that someone just came on in
ZoneManager zmgr = _zonereg.getZoneManager(summary.zoneId);
zmgr.bodyDidEnterZone(source, summary.zoneId);
} catch (ServiceFailedException sfe) {
sendResponse(source, invid,
MOVE_FAILED_RESPONSE, sfe.getMessage());
} catch (InvocationException ie) {
listener.requestFailed(ie.getMessage());
}
}
@@ -182,23 +178,21 @@ public class ZoneProvider
* request to move to the specified new zone and scene. This is the
* zone-equivalent to {@link LocationProvider#moveBody}.
*/
public static void moveBody (BodyObject source, int zoneId, int sceneId)
public void moveBody (BodyObject source, int zoneId, int sceneId)
{
// first remove them from their old place
LocationProvider.leaveOccupiedPlace(source);
_locprov.leaveOccupiedPlace(source);
// then send a move notification
_invmgr.sendNotification(
source.getOid(), MODULE_NAME, MOVE_NOTIFICATION,
new Object[] { new Integer(zoneId), new Integer(sceneId) });
// then send a forced move notification
ZoneSender.forcedMove(source, zoneId, sceneId);
}
/** The invocation manager with which we interact. */
protected static InvocationManager _invmgr;
/** The entity that handles basic location changes. */
protected LocationProvider _locprov;
/** The zone registry with which we communicate. */
protected static ZoneRegistry _zonereg;
protected ZoneRegistry _zonereg;
/** The scene registry with which we communicate. */
protected static SceneRegistry _screg;
protected SceneRegistry _screg;
}
@@ -1,11 +1,13 @@
//
// $Id: ZoneRegistry.java,v 1.7 2002/05/26 02:24:46 mdb Exp $
// $Id: ZoneRegistry.java,v 1.8 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.server;
import com.samskivert.util.HashIntMap;
import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.server.PlaceRegistry;
import com.threerings.whirled.server.SceneRegistry;
import com.threerings.whirled.zone.Log;
@@ -17,15 +19,19 @@ import com.threerings.whirled.zone.util.ZoneUtil;
*/
public class ZoneRegistry
{
/** Implements the server-side of the zone-related services. */
public ZoneProvider zoneprov;
/**
* Creates a zone manager with the supplied configuration.
*/
public ZoneRegistry (InvocationManager invmgr, SceneRegistry screg)
public ZoneRegistry (InvocationManager invmgr, PlaceRegistry plreg,
SceneRegistry screg)
{
// create a zone provider and register it with the invocation
// services
ZoneProvider provider = new ZoneProvider(invmgr, this, screg);
invmgr.registerProvider(ZoneProvider.MODULE_NAME, provider);
zoneprov = new ZoneProvider(plreg.locprov, this, screg);
invmgr.registerDispatcher(new ZoneDispatcher(zoneprov), true);
}
/**
@@ -0,0 +1,30 @@
//
// $Id: ZoneSender.java,v 1.1 2002/08/14 19:07:58 mdb Exp $
package com.threerings.whirled.zone.server;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.server.InvocationSender;
import com.threerings.whirled.zone.client.ZoneDecoder;
import com.threerings.whirled.zone.client.ZoneReceiver;
/**
* Used to issue notifications to a {@link ZoneReceiver} instance on a
* client.
*/
public class ZoneSender extends InvocationSender
{
/**
* Issues a notification that will result in a call to {@link
* ZoneReceiver#forcedMove} on a client.
*/
public static void forcedMove (
ClientObject target, int arg1, int arg2)
{
sendNotification(
target, ZoneDecoder.RECEIVER_CODE, ZoneDecoder.FORCED_MOVE,
new Object[] { new Integer(arg1), new Integer(arg2) });
}
// Generated on 11:25:47 08/12/02.
}