Removed a bunch of code to generate failure responses as it's now handled

automagically!


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1269 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-04-17 18:26:30 +00:00
parent 496732db3a
commit 51c7f6b527
3 changed files with 33 additions and 79 deletions
@@ -1,5 +1,5 @@
// //
// $Id: TableDirector.java,v 1.6 2002/03/18 23:21:26 mdb Exp $ // $Id: TableDirector.java,v 1.7 2002/04/17 18:26:29 mdb Exp $
package com.threerings.parlor.client; package com.threerings.parlor.client;
@@ -253,7 +253,7 @@ public class TableDirector
* @param invid the invocation id of the creation request. * @param invid the invocation id of the creation request.
* @param reason a reason code explaining the failure. * @param reason a reason code explaining the failure.
*/ */
public void handleCreateFailed (int invid, String reason) public void handleCreateTableFailed (int invid, String reason)
{ {
Log.warning("Table creation failed [reason=" + reason + "]."); Log.warning("Table creation failed [reason=" + reason + "].");
} }
@@ -265,7 +265,7 @@ public class TableDirector
* @param invid the invocation id of the join request. * @param invid the invocation id of the join request.
* @param reason a reason code explaining the failure. * @param reason a reason code explaining the failure.
*/ */
public void handleJoinFailed (int invid, String reason) public void handleJoinTableFailed (int invid, String reason)
{ {
Log.warning("Join table failed [reason=" + reason + "]."); Log.warning("Join table failed [reason=" + reason + "].");
} }
@@ -277,7 +277,7 @@ public class TableDirector
* @param invid the invocation id of the leave request. * @param invid the invocation id of the leave request.
* @param reason a reason code explaining the failure. * @param reason a reason code explaining the failure.
*/ */
public void handleLeaveFailed (int invid, String reason) public void handleLeaveTableFailed (int invid, String reason)
{ {
Log.warning("Leave table failed [reason=" + reason + "]."); Log.warning("Leave table failed [reason=" + reason + "].");
} }
@@ -1,5 +1,5 @@
// //
// $Id: ParlorCodes.java,v 1.2 2002/04/15 18:06:20 mdb Exp $ // $Id: ParlorCodes.java,v 1.3 2002/04/17 18:26:29 mdb Exp $
package com.threerings.parlor.data; package com.threerings.parlor.data;
@@ -31,11 +31,6 @@ public interface ParlorCodes extends InvocationCodes
* ParlorDirector#handleInviteReceived}. */ * ParlorDirector#handleInviteReceived}. */
public static final String INVITE_RECEIVED_RESPONSE = "InviteReceived"; public static final String INVITE_RECEIVED_RESPONSE = "InviteReceived";
/** The response identifier for a rejceted invite request. This is
* mapped by the invocation services to a call to {@link
* ParlorDirector#handleInviteFailed}. */
public static final String INVITE_FAILED_RESPONSE = "InviteFailed";
/** The message identifier for an invitation cancellation request or /** The message identifier for an invitation cancellation request or
* notification. The notification is mapped by the invocation services * notification. The notification is mapped by the invocation services
* to a call to {@link * to a call to {@link
@@ -70,27 +65,12 @@ public interface ParlorCodes extends InvocationCodes
* TableDirector#handleTableCreated}. */ * TableDirector#handleTableCreated}. */
public static final String TABLE_CREATED_RESPONSE = "TableCreated"; public static final String TABLE_CREATED_RESPONSE = "TableCreated";
/** The response identifier for a create failed response. This is
* mapped by the invocation services to a call to {@link
* TableDirector#handleCreateFailed}. */
public static final String CREATE_FAILED_RESPONSE = "CreateFailed";
/** The message identifier for a join table request. */ /** The message identifier for a join table request. */
public static final String JOIN_TABLE_REQUEST = "JoinTable"; public static final String JOIN_TABLE_REQUEST = "JoinTable";
/** The response identifier for a join failed response. This is mapped
* by the invocation services to a call to {@link
* TableDirector#handleJoinFailed}. */
public static final String JOIN_FAILED_RESPONSE = "JoinFailed";
/** The message identifier for a leave table request. */ /** The message identifier for a leave table request. */
public static final String LEAVE_TABLE_REQUEST = "LeaveTable"; public static final String LEAVE_TABLE_REQUEST = "LeaveTable";
/** The response identifier for a leave failed response. This is
* mapped by the invocation services to a call to {@link
* TableDirector#handleLeaveFailed}. */
public static final String LEAVE_FAILED_RESPONSE = "LeaveFailed";
/** An error code returned when a user requests to join a table that /** An error code returned when a user requests to join a table that
* doesn't exist. */ * doesn't exist. */
public static final String NO_SUCH_TABLE = "m.no_such_table"; public static final String NO_SUCH_TABLE = "m.no_such_table";
@@ -1,5 +1,5 @@
// //
// $Id: ParlorProvider.java,v 1.11 2002/04/15 16:28:02 shaper Exp $ // $Id: ParlorProvider.java,v 1.12 2002/04/17 18:26:30 mdb Exp $
package com.threerings.parlor.server; package com.threerings.parlor.server;
@@ -42,6 +42,7 @@ public class ParlorProvider
*/ */
public void handleInviteRequest ( public void handleInviteRequest (
BodyObject source, int invid, String invitee, GameConfig config) BodyObject source, int invid, String invitee, GameConfig config)
throws ServiceFailedException
{ {
// Log.info("Handling invite request [source=" + source + // Log.info("Handling invite request [source=" + source +
// ", invid=" + invid + ", invitee=" + invitee + // ", invid=" + invid + ", invitee=" + invitee +
@@ -50,23 +51,15 @@ public class ParlorProvider
String rsp = null; String rsp = null;
// ensure that the invitee is online at present // ensure that the invitee is online at present
try { BodyObject target = CrowdServer.lookupBody(invitee);
BodyObject target = CrowdServer.lookupBody(invitee); if (target == null) {
if (target == null) { throw new ServiceFailedException(INVITEE_NOT_ONLINE);
throw new ServiceFailedException(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));
} catch (ServiceFailedException sfe) {
// the exception message is the code indicating the reason
// for the invitation rejection
sendResponse(source, invid, INVITE_FAILED_RESPONSE,
sfe.getMessage());
} }
// submit the invite request to the parlor manager
int inviteId = _pmgr.invite(source, target, config);
sendResponse(source, invid, INVITE_RECEIVED_RESPONSE,
new Integer(inviteId));
} }
/** /**
@@ -96,24 +89,17 @@ public class ParlorProvider
*/ */
public void handleCreateTableRequest ( public void handleCreateTableRequest (
BodyObject source, int invid, int lobbyOid, GameConfig config) BodyObject source, int invid, int lobbyOid, GameConfig config)
throws ServiceFailedException
{ {
Log.info("Handling create table request [source=" + source + Log.info("Handling create table request [source=" + source +
", invid=" + invid + ", lobbyOid=" + lobbyOid + ", invid=" + invid + ", lobbyOid=" + lobbyOid +
", config=" + config + "]."); ", config=" + config + "].");
try { // pass the creation request on to the table manager
// pass the creation request on to the table manager TableManager tmgr = getTableManager(lobbyOid);
TableManager tmgr = getTableManager(lobbyOid); int tableId = tmgr.createTable(source, config);
int tableId = tmgr.createTable(source, config); sendResponse(source, invid, TABLE_CREATED_RESPONSE,
sendResponse(source, invid, TABLE_CREATED_RESPONSE, new Integer(tableId));
new Integer(tableId));
} catch (ServiceFailedException sfe) {
// the exception message is the code indicating the reason for
// the creation rejection
sendResponse(source, invid, CREATE_FAILED_RESPONSE,
sfe.getMessage());
}
} }
/** /**
@@ -121,24 +107,18 @@ public class ParlorProvider
*/ */
public void handleJoinTableRequest ( public void handleJoinTableRequest (
BodyObject source, int invid, int lobbyOid, int tableId, int position) BodyObject source, int invid, int lobbyOid, int tableId, int position)
throws ServiceFailedException
{ {
Log.info("Handling join table request [source=" + source + Log.info("Handling join table request [source=" + source +
", invid=" + invid + ", lobbyOid=" + lobbyOid + ", invid=" + invid + ", lobbyOid=" + lobbyOid +
", tableId=" + tableId + ", position=" + position + "]."); ", tableId=" + tableId + ", position=" + position + "].");
try { // pass the join request on to the table manager
// pass the join request on to the table manager TableManager tmgr = getTableManager(lobbyOid);
TableManager tmgr = getTableManager(lobbyOid); tmgr.joinTable(source, tableId, position);
tmgr.joinTable(source, tableId, position);
// there is normally no response. the client will see
// themselves show up in the table that they joined
} catch (ServiceFailedException sfe) { // there is normally no success response. the client will see
// the exception message is the code indicating the reason for // themselves show up in the table that they joined
// the creation rejection
sendResponse(source, invid, JOIN_FAILED_RESPONSE,
sfe.getMessage());
}
} }
/** /**
@@ -146,24 +126,18 @@ public class ParlorProvider
*/ */
public void handleLeaveTableRequest ( public void handleLeaveTableRequest (
BodyObject source, int invid, int lobbyOid, int tableId) BodyObject source, int invid, int lobbyOid, int tableId)
throws ServiceFailedException
{ {
Log.info("Handling leave table request [source=" + source + Log.info("Handling leave table request [source=" + source +
", invid=" + invid + ", lobbyOid=" + lobbyOid + ", invid=" + invid + ", lobbyOid=" + lobbyOid +
", tableId=" + tableId + "]."); ", tableId=" + tableId + "].");
try { // pass the join request on to the table manager
// pass the join request on to the table manager TableManager tmgr = getTableManager(lobbyOid);
TableManager tmgr = getTableManager(lobbyOid); tmgr.leaveTable(source, tableId);
tmgr.leaveTable(source, tableId);
// there is normally no response. the client will see
// themselves removed from the table they just left
} catch (ServiceFailedException sfe) { // there is normally no success response. the client will see
// the exception message is the code indicating the reason for // themselves removed from the table they just left
// the creation rejection
sendResponse(source, invid, LEAVE_FAILED_RESPONSE,
sfe.getMessage());
}
} }
/** /**