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
@@ -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;