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:
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// $Id: ParlorDispatcher.java,v 1.1 2002/08/14 19:07:54 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.server;
|
||||
|
||||
import com.threerings.parlor.client.ParlorService;
|
||||
import com.threerings.parlor.client.ParlorService.InviteListener;
|
||||
import com.threerings.parlor.client.ParlorService.TableListener;
|
||||
import com.threerings.parlor.data.ParlorMarshaller;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService.InvocationListener;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.server.InvocationDispatcher;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
|
||||
/**
|
||||
* Dispatches requests to the {@link ParlorProvider}.
|
||||
*/
|
||||
public class ParlorDispatcher extends InvocationDispatcher
|
||||
{
|
||||
/**
|
||||
* Creates a dispatcher that may be registered to dispatch invocation
|
||||
* service requests for the specified provider.
|
||||
*/
|
||||
public ParlorDispatcher (ParlorProvider provider)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public InvocationMarshaller createMarshaller ()
|
||||
{
|
||||
return new ParlorMarshaller();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchRequest (
|
||||
ClientObject source, int methodId, Object[] args)
|
||||
throws InvocationException
|
||||
{
|
||||
switch (methodId) {
|
||||
case ParlorMarshaller.INVITE:
|
||||
((ParlorProvider)provider).invite(
|
||||
source,
|
||||
(String)args[0], (GameConfig)args[1], (InviteListener)args[2]
|
||||
);
|
||||
return;
|
||||
|
||||
case ParlorMarshaller.RESPOND:
|
||||
((ParlorProvider)provider).respond(
|
||||
source,
|
||||
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), (Object)args[2], (InvocationListener)args[3]
|
||||
);
|
||||
return;
|
||||
|
||||
case ParlorMarshaller.CANCEL:
|
||||
((ParlorProvider)provider).cancel(
|
||||
source,
|
||||
((Integer)args[0]).intValue(), (InvocationListener)args[1]
|
||||
);
|
||||
return;
|
||||
|
||||
case ParlorMarshaller.CREATE_TABLE:
|
||||
((ParlorProvider)provider).createTable(
|
||||
source,
|
||||
((Integer)args[0]).intValue(), (GameConfig)args[1], (TableListener)args[2]
|
||||
);
|
||||
return;
|
||||
|
||||
case ParlorMarshaller.JOIN_TABLE:
|
||||
((ParlorProvider)provider).joinTable(
|
||||
source,
|
||||
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), ((Integer)args[2]).intValue(), (InvocationListener)args[3]
|
||||
);
|
||||
return;
|
||||
|
||||
case ParlorMarshaller.LEAVE_TABLE:
|
||||
((ParlorProvider)provider).leaveTable(
|
||||
source,
|
||||
((Integer)args[0]).intValue(), ((Integer)args[1]).intValue(), (InvocationListener)args[2]
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
//
|
||||
// $Id: ParlorManager.java,v 1.18 2002/04/15 16:28:02 shaper Exp $
|
||||
// $Id: ParlorManager.java,v 1.19 2002/08/14 19:07:54 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.server;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
import com.threerings.presents.server.InvocationManager;
|
||||
import com.threerings.presents.server.ServiceFailedException;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.server.CrowdServer;
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
|
||||
import com.threerings.parlor.Log;
|
||||
import com.threerings.parlor.data.ParlorCodes;
|
||||
@@ -26,6 +26,9 @@ import com.threerings.parlor.game.GameManager;
|
||||
public class ParlorManager
|
||||
implements ParlorCodes
|
||||
{
|
||||
/** Provides the server-side implementation of the parlor services. */
|
||||
public ParlorProvider parprov;
|
||||
|
||||
/**
|
||||
* Initializes the parlor manager. This should be called by the server
|
||||
* that is making use of the parlor services on the single instance of
|
||||
@@ -33,15 +36,17 @@ public class ParlorManager
|
||||
*
|
||||
* @param invmgr a reference to the invocation manager in use by this
|
||||
* server.
|
||||
* @param plreg a reference to the place registry to be used by the
|
||||
* parlor manager when creating game places.
|
||||
*/
|
||||
public void init (InvocationManager invmgr)
|
||||
public void init (InvocationManager invmgr, PlaceRegistry plreg)
|
||||
{
|
||||
// register our invocation provider
|
||||
ParlorProvider pprov = new ParlorProvider(this);
|
||||
invmgr.registerProvider(MODULE_NAME, pprov);
|
||||
// create and register our invocation provider
|
||||
parprov = new ParlorProvider(this);
|
||||
invmgr.registerDispatcher(new ParlorDispatcher(parprov), true);
|
||||
|
||||
// keep this around for later
|
||||
_invmgr = invmgr;
|
||||
// keep this for later
|
||||
_plreg = plreg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,14 +61,14 @@ public class ParlorManager
|
||||
* @return the invitation identifier for the newly created invitation
|
||||
* record.
|
||||
*
|
||||
* @exception ServiceFailedException thrown if the invitation was not
|
||||
* @exception InvocationException thrown if the invitation was not
|
||||
* able to be processed for some reason (like the invited player has
|
||||
* requested not to be disturbed). The explanation will be provided in
|
||||
* the message data of the exception.
|
||||
*/
|
||||
public int invite (BodyObject inviter, BodyObject invitee,
|
||||
GameConfig config)
|
||||
throws ServiceFailedException
|
||||
throws InvocationException
|
||||
{
|
||||
// Log.info("Received invitation request [inviter=" + inviter +
|
||||
// ", invitee=" + invitee + ", config=" + config + "].");
|
||||
@@ -79,10 +84,8 @@ public class ParlorManager
|
||||
_invites.put(invite.inviteId, invite);
|
||||
|
||||
// deliver an invite notification to the invitee
|
||||
Object[] args = new Object[] {
|
||||
new Integer(invite.inviteId), inviter.username, config };
|
||||
_invmgr.sendNotification(
|
||||
invitee.getOid(), MODULE_NAME, INVITE_ID, args);
|
||||
ParlorSender.sendInvite(invitee, invite.inviteId,
|
||||
inviter.username, config);
|
||||
|
||||
// and let the caller know the invite id we assigned
|
||||
return invite.inviteId;
|
||||
@@ -126,10 +129,8 @@ public class ParlorManager
|
||||
|
||||
// let the other user know that a response was made to this
|
||||
// invitation
|
||||
Object[] args = new Object[] {
|
||||
new Integer(invite.inviteId), new Integer(code), arg };
|
||||
_invmgr.sendNotification(
|
||||
invite.inviter.getOid(), MODULE_NAME, RESPOND_INVITE_ID, args);
|
||||
ParlorSender.sendInviteResponse(
|
||||
invite.inviter, invite.inviteId, code, arg);
|
||||
|
||||
switch (code) {
|
||||
case INVITATION_ACCEPTED:
|
||||
@@ -187,7 +188,7 @@ public class ParlorManager
|
||||
// started up (which is done by the place registry once the
|
||||
// game object creation has completed)
|
||||
GameManager gmgr = (GameManager)
|
||||
CrowdServer.plreg.createPlace(invite.config, null);
|
||||
_plreg.createPlace(invite.config, null);
|
||||
|
||||
// provide the game manager with the player list
|
||||
gmgr.setPlayers(new String[] {
|
||||
@@ -242,8 +243,8 @@ public class ParlorManager
|
||||
}
|
||||
}
|
||||
|
||||
/** A reference to the invocation manager in operation on this server. */
|
||||
protected InvocationManager _invmgr;
|
||||
/** The place registry with which we operate. */
|
||||
protected PlaceRegistry _plreg;
|
||||
|
||||
/** The table of pending invitations. */
|
||||
protected HashIntMap _invites = new HashIntMap();
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
//
|
||||
// $Id: ParlorProvider.java,v 1.12 2002/04/17 18:26:30 mdb Exp $
|
||||
// $Id: ParlorProvider.java,v 1.13 2002/08/14 19:07:54 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.server;
|
||||
|
||||
import com.threerings.presents.client.InvocationService.InvocationListener;
|
||||
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.server.CrowdServer;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
|
||||
import com.threerings.parlor.Log;
|
||||
import com.threerings.parlor.client.ParlorService.InviteListener;
|
||||
import com.threerings.parlor.client.ParlorService.TableListener;
|
||||
import com.threerings.parlor.data.ParlorCodes;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
|
||||
@@ -20,7 +24,7 @@ import com.threerings.parlor.game.GameConfig;
|
||||
* Primarily these are the matchmaking mechanisms.
|
||||
*/
|
||||
public class ParlorProvider
|
||||
extends InvocationProvider implements ParlorCodes
|
||||
implements InvocationProvider, ParlorCodes
|
||||
{
|
||||
/**
|
||||
* Constructs a parlor provider instance which will be used to handle
|
||||
@@ -40,82 +44,79 @@ public class ParlorProvider
|
||||
* Processes a request from the client to invite another user to play
|
||||
* a game.
|
||||
*/
|
||||
public void handleInviteRequest (
|
||||
BodyObject source, int invid, String invitee, GameConfig config)
|
||||
throws ServiceFailedException
|
||||
public void invite (ClientObject caller, String invitee,
|
||||
GameConfig config, InviteListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
// Log.info("Handling invite request [source=" + source +
|
||||
// ", invid=" + invid + ", invitee=" + invitee +
|
||||
// ", config=" + config + "].");
|
||||
// ", invitee=" + invitee + ", config=" + config + "].");
|
||||
|
||||
BodyObject source = (BodyObject)caller;
|
||||
String rsp = null;
|
||||
|
||||
// ensure that the invitee is online at present
|
||||
BodyObject target = CrowdServer.lookupBody(invitee);
|
||||
if (target == null) {
|
||||
throw new ServiceFailedException(INVITEE_NOT_ONLINE);
|
||||
throw new InvocationException(INVITEE_NOT_ONLINE);
|
||||
}
|
||||
|
||||
// submit the invite request to the parlor manager
|
||||
int inviteId = _pmgr.invite(source, target, config);
|
||||
sendResponse(source, invid, INVITE_RECEIVED_RESPONSE,
|
||||
new Integer(inviteId));
|
||||
listener.inviteReceived(inviteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request from the client to respond to an outstanding
|
||||
* invitation by accepting, refusing, or countering it.
|
||||
*/
|
||||
public void handleRespondInviteRequest (
|
||||
BodyObject source, int invid, int inviteId, int code, Object arg)
|
||||
public void respond (ClientObject caller, int inviteId, int code,
|
||||
Object arg, InvocationListener listener)
|
||||
{
|
||||
// pass this on to the parlor manager
|
||||
_pmgr.respondToInvite(source, inviteId, code, arg);
|
||||
_pmgr.respondToInvite((BodyObject)caller, inviteId, code, arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request from the client to cancel an outstanding
|
||||
* invitation.
|
||||
*/
|
||||
public void handleCancelInviteRequest (
|
||||
BodyObject source, int invid, int inviteId)
|
||||
public void cancel (ClientObject caller, int inviteId,
|
||||
InvocationListener listener)
|
||||
{
|
||||
// pass this on to the parlor manager
|
||||
_pmgr.cancelInvite(source, inviteId);
|
||||
_pmgr.cancelInvite((BodyObject)caller, inviteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request from the client to create a new table.
|
||||
*/
|
||||
public void handleCreateTableRequest (
|
||||
BodyObject source, int invid, int lobbyOid, GameConfig config)
|
||||
throws ServiceFailedException
|
||||
public void createTable (ClientObject caller, int lobbyOid,
|
||||
GameConfig config, TableListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
Log.info("Handling create table request [source=" + source +
|
||||
", invid=" + invid + ", lobbyOid=" + lobbyOid +
|
||||
", config=" + config + "].");
|
||||
Log.info("Handling create table request [caller=" + caller +
|
||||
", lobbyOid=" + lobbyOid + ", config=" + config + "].");
|
||||
|
||||
// pass the creation request on to the table manager
|
||||
TableManager tmgr = getTableManager(lobbyOid);
|
||||
int tableId = tmgr.createTable(source, config);
|
||||
sendResponse(source, invid, TABLE_CREATED_RESPONSE,
|
||||
new Integer(tableId));
|
||||
int tableId = tmgr.createTable((BodyObject)caller, config);
|
||||
listener.tableCreated(tableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request from the client to join an existing table.
|
||||
*/
|
||||
public void handleJoinTableRequest (
|
||||
BodyObject source, int invid, int lobbyOid, int tableId, int position)
|
||||
throws ServiceFailedException
|
||||
public void joinTable (ClientObject caller, int lobbyOid, int tableId,
|
||||
int position, InvocationListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
Log.info("Handling join table request [source=" + source +
|
||||
", invid=" + invid + ", lobbyOid=" + lobbyOid +
|
||||
", tableId=" + tableId + ", position=" + position + "].");
|
||||
Log.info("Handling join table request [caller=" + caller +
|
||||
", lobbyOid=" + lobbyOid + ", tableId=" + tableId +
|
||||
", position=" + position + "].");
|
||||
|
||||
// pass the join request on to the table manager
|
||||
TableManager tmgr = getTableManager(lobbyOid);
|
||||
tmgr.joinTable(source, tableId, position);
|
||||
tmgr.joinTable((BodyObject)caller, tableId, position);
|
||||
|
||||
// there is normally no success response. the client will see
|
||||
// themselves show up in the table that they joined
|
||||
@@ -124,17 +125,16 @@ public class ParlorProvider
|
||||
/**
|
||||
* Processes a request from the client to leave an existing table.
|
||||
*/
|
||||
public void handleLeaveTableRequest (
|
||||
BodyObject source, int invid, int lobbyOid, int tableId)
|
||||
throws ServiceFailedException
|
||||
public void leaveTable (ClientObject caller, int lobbyOid, int tableId,
|
||||
InvocationListener listener)
|
||||
throws InvocationException
|
||||
{
|
||||
Log.info("Handling leave table request [source=" + source +
|
||||
", invid=" + invid + ", lobbyOid=" + lobbyOid +
|
||||
", tableId=" + tableId + "].");
|
||||
Log.info("Handling leave table request [caller=" + caller +
|
||||
", lobbyOid=" + lobbyOid + ", tableId=" + tableId + "].");
|
||||
|
||||
// pass the join request on to the table manager
|
||||
TableManager tmgr = getTableManager(lobbyOid);
|
||||
tmgr.leaveTable(source, tableId);
|
||||
tmgr.leaveTable((BodyObject)caller, tableId);
|
||||
|
||||
// there is normally no success response. the client will see
|
||||
// themselves removed from the table they just left
|
||||
@@ -145,25 +145,25 @@ public class ParlorProvider
|
||||
* casts it to a table lobby manager and obtains the associated table
|
||||
* manager reference.
|
||||
*
|
||||
* @exception ServiceFailedException thrown if something goes wrong
|
||||
* @exception InvocationException thrown if something goes wrong
|
||||
* along the way like no place manager exists or the place manager
|
||||
* that does exist doesn't implement table lobby manager.
|
||||
*/
|
||||
protected TableManager getTableManager (int lobbyOid)
|
||||
throws ServiceFailedException
|
||||
throws InvocationException
|
||||
{
|
||||
PlaceManager plmgr = CrowdServer.plreg.getPlaceManager(lobbyOid);
|
||||
if (plmgr == null) {
|
||||
Log.warning("No place manager exists from which to obtain " +
|
||||
"table manager reference [ploid=" + lobbyOid + "].");
|
||||
throw new ServiceFailedException(INTERNAL_ERROR);
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
// sanity check
|
||||
if (!(plmgr instanceof TableManagerProvider)) {
|
||||
Log.warning("Place manager not a table lobby manager " +
|
||||
"[plmgr=" + plmgr + "].");
|
||||
throw new ServiceFailedException(INTERNAL_ERROR);
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
return ((TableManagerProvider)plmgr).getTableManager();
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// $Id: ParlorSender.java,v 1.1 2002/08/14 19:07:54 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.server;
|
||||
|
||||
import com.threerings.parlor.client.ParlorDecoder;
|
||||
import com.threerings.parlor.client.ParlorReceiver;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.server.InvocationSender;
|
||||
|
||||
/**
|
||||
* Used to issue notifications to a {@link ParlorReceiver} instance on a
|
||||
* client.
|
||||
*/
|
||||
public class ParlorSender extends InvocationSender
|
||||
{
|
||||
/**
|
||||
* Issues a notification that will result in a call to {@link
|
||||
* ParlorReceiver#gameIsReady} on a client.
|
||||
*/
|
||||
public static void gameIsReady (
|
||||
ClientObject target, int arg1)
|
||||
{
|
||||
sendNotification(
|
||||
target, ParlorDecoder.RECEIVER_CODE, ParlorDecoder.GAME_IS_READY,
|
||||
new Object[] { new Integer(arg1) });
|
||||
}
|
||||
|
||||
/**
|
||||
* Issues a notification that will result in a call to {@link
|
||||
* ParlorReceiver#receivedInvite} on a client.
|
||||
*/
|
||||
public static void sendInvite (
|
||||
ClientObject target, int arg1, String arg2, GameConfig arg3)
|
||||
{
|
||||
sendNotification(
|
||||
target, ParlorDecoder.RECEIVER_CODE, ParlorDecoder.RECEIVED_INVITE,
|
||||
new Object[] { new Integer(arg1), arg2, arg3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Issues a notification that will result in a call to {@link
|
||||
* ParlorReceiver#receivedInviteResponse} on a client.
|
||||
*/
|
||||
public static void sendInviteResponse (
|
||||
ClientObject target, int arg1, int arg2, Object arg3)
|
||||
{
|
||||
sendNotification(
|
||||
target, ParlorDecoder.RECEIVER_CODE, ParlorDecoder.RECEIVED_INVITE_RESPONSE,
|
||||
new Object[] { new Integer(arg1), new Integer(arg2), arg3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Issues a notification that will result in a call to {@link
|
||||
* ParlorReceiver#receivedInviteCancellation} on a client.
|
||||
*/
|
||||
public static void sendInviteCancellation (
|
||||
ClientObject target, int arg1)
|
||||
{
|
||||
sendNotification(
|
||||
target, ParlorDecoder.RECEIVER_CODE, ParlorDecoder.RECEIVED_INVITE_CANCELLATION,
|
||||
new Object[] { new Integer(arg1) });
|
||||
}
|
||||
|
||||
// Generated on 11:25:47 08/12/02.
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TableManager.java,v 1.6 2002/07/23 05:54:52 mdb Exp $
|
||||
// $Id: TableManager.java,v 1.7 2002/08/14 19:07:54 mdb Exp $
|
||||
|
||||
package com.threerings.parlor.server;
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.threerings.presents.dobj.ObjectDeathListener;
|
||||
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
||||
import com.threerings.presents.dobj.ObjectRemovedEvent;
|
||||
import com.threerings.presents.dobj.OidListListener;
|
||||
import com.threerings.presents.server.ServiceFailedException;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
@@ -69,12 +69,12 @@ public class TableManager
|
||||
*
|
||||
* @return the id of the newly created table.
|
||||
*
|
||||
* @exception ServiceFailedException thrown if the table creation was
|
||||
* @exception InvocationException thrown if the table creation was
|
||||
* not able processed for some reason. The explanation will be
|
||||
* provided in the message data of the exception.
|
||||
*/
|
||||
public int createTable (BodyObject creator, GameConfig config)
|
||||
throws ServiceFailedException
|
||||
throws InvocationException
|
||||
{
|
||||
// make sure the game config implements TableConfig
|
||||
if (!(config instanceof TableConfig)) {
|
||||
@@ -82,7 +82,7 @@ public class TableManager
|
||||
"using the table services [creator=" + creator +
|
||||
", lobby=" + _plobj.getOid() +
|
||||
", config=" + config + "].");
|
||||
throw new ServiceFailedException(INTERNAL_ERROR);
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
// make sure the creator is an occupant of the lobby in which
|
||||
@@ -91,7 +91,7 @@ public class TableManager
|
||||
Log.warning("Requested to create a table in a lobby not " +
|
||||
"occupied by the creator [creator=" + creator +
|
||||
", loboid=" + _plobj.getOid() + "].");
|
||||
throw new ServiceFailedException(INTERNAL_ERROR);
|
||||
throw new InvocationException(INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
// create a brand spanking new table
|
||||
@@ -105,7 +105,7 @@ public class TableManager
|
||||
"table!? [table=" + table + ", creator=" + creator +
|
||||
", error=" + error + "].");
|
||||
// bail out now and abort the table creation process
|
||||
throw new ServiceFailedException(error);
|
||||
throw new InvocationException(error);
|
||||
}
|
||||
|
||||
// stick the table into the table lobby object
|
||||
@@ -126,7 +126,7 @@ public class TableManager
|
||||
* the specified position. If the user successfully joins the table,
|
||||
* the function will return normally. If they are not able to join for
|
||||
* some reason (the slot is already full, etc.), a {@link
|
||||
* ServiceFailedException} will be thrown with a message code that
|
||||
* InvocationException} will be thrown with a message code that
|
||||
* describes the reason for failure. If the user does successfully
|
||||
* join, they will be added to the table entry in the tables set in
|
||||
* the place object that is hosting the table.
|
||||
@@ -136,17 +136,17 @@ public class TableManager
|
||||
* @param tableId the id of the table to be joined.
|
||||
* @param position the position at which to join the table.
|
||||
*
|
||||
* @exception ServiceFailedException thrown if the joining was not
|
||||
* able processed for some reason. The explanation will be provided in
|
||||
* the message data of the exception.
|
||||
* @exception InvocationException thrown if the joining was not able
|
||||
* processed for some reason. The explanation will be provided in the
|
||||
* message data of the exception.
|
||||
*/
|
||||
public void joinTable (BodyObject joiner, int tableId, int position)
|
||||
throws ServiceFailedException
|
||||
throws InvocationException
|
||||
{
|
||||
// look the table up
|
||||
Table table = (Table)_tables.get(tableId);
|
||||
if (table == null) {
|
||||
throw new ServiceFailedException(NO_SUCH_TABLE);
|
||||
throw new InvocationException(NO_SUCH_TABLE);
|
||||
}
|
||||
|
||||
// request that the user be added to the table at that position
|
||||
@@ -154,7 +154,7 @@ public class TableManager
|
||||
table.setOccupant(position, joiner.username, joiner.getOid());
|
||||
// if that failed, report the error
|
||||
if (error != null) {
|
||||
throw new ServiceFailedException(error);
|
||||
throw new InvocationException(error);
|
||||
}
|
||||
|
||||
// determine whether or not it's time to start the game
|
||||
@@ -188,29 +188,29 @@ public class TableManager
|
||||
* table. If the user successfully leaves the table, the function will
|
||||
* return normally. If they are not able to leave for some reason
|
||||
* (they aren't sitting at the table, etc.), a {@link
|
||||
* ServiceFailedException} will be thrown with a message code that
|
||||
* InvocationException} will be thrown with a message code that
|
||||
* describes the reason for failure.
|
||||
*
|
||||
* @param leaver the body object of the user that wishes to leave the
|
||||
* table.
|
||||
* @param tableId the id of the table to be left.
|
||||
*
|
||||
* @exception ServiceFailedException thrown if the leaving was not
|
||||
* able processed for some reason. The explanation will be provided in
|
||||
* the message data of the exception.
|
||||
* @exception InvocationException thrown if the leaving was not able
|
||||
* processed for some reason. The explanation will be provided in the
|
||||
* message data of the exception.
|
||||
*/
|
||||
public void leaveTable (BodyObject leaver, int tableId)
|
||||
throws ServiceFailedException
|
||||
throws InvocationException
|
||||
{
|
||||
// look the table up
|
||||
Table table = (Table)_tables.get(tableId);
|
||||
if (table == null) {
|
||||
throw new ServiceFailedException(NO_SUCH_TABLE);
|
||||
throw new InvocationException(NO_SUCH_TABLE);
|
||||
}
|
||||
|
||||
// request that the user be removed from the table
|
||||
if (!table.clearOccupant(leaver.username)) {
|
||||
throw new ServiceFailedException(NOT_AT_TABLE);
|
||||
throw new InvocationException(NOT_AT_TABLE);
|
||||
}
|
||||
|
||||
// remove the mapping from this user to the table
|
||||
|
||||
Reference in New Issue
Block a user