Moved parlor invocation service codes into ParlorCodes. Started work on
server side of parlor invocation services. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@370 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// $Id: ParlorCodes.java,v 1.1 2001/10/01 22:17:34 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.parlor.client;
|
||||||
|
|
||||||
|
import com.threerings.cocktail.cher.client.InvocationCodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains codes used by the parlor invocation services.
|
||||||
|
*/
|
||||||
|
public interface ParlorCodes extends InvocationCodes
|
||||||
|
{
|
||||||
|
/** The module name for the parlor services. */
|
||||||
|
public static final String MODULE_NAME = "parlor";
|
||||||
|
|
||||||
|
/** The message identifier for an invitation creation request or
|
||||||
|
* notification. */
|
||||||
|
public static final String INVITE_ID = "Invite";
|
||||||
|
|
||||||
|
/** The message identifier for an invitation cancellation request or
|
||||||
|
* notification. */
|
||||||
|
public static final String CANCEL_INVITE_ID = "CancelInvite";
|
||||||
|
|
||||||
|
/** The message identifier for an invitation response request or
|
||||||
|
* notification. */
|
||||||
|
public static final String RESPOND_INVITE_ID = "RespondInvite";
|
||||||
|
|
||||||
|
/** The response code for an accepted invitation. */
|
||||||
|
public static final int INVITATION_ACCEPTED = 0;
|
||||||
|
|
||||||
|
/** The response code for a refused invitation. */
|
||||||
|
public static final int INVITATION_REFUSED = 1;
|
||||||
|
|
||||||
|
/** The response code for a countered invitation. */
|
||||||
|
public static final int INVITATION_COUNTERED = 2;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ParlorDirector.java,v 1.3 2001/10/01 06:19:15 mdb Exp $
|
// $Id: ParlorDirector.java,v 1.4 2001/10/01 22:17:34 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.client;
|
package com.threerings.parlor.client;
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ import com.threerings.parlor.util.ParlorContext;
|
|||||||
* that started.
|
* that started.
|
||||||
*/
|
*/
|
||||||
public class ParlorDirector
|
public class ParlorDirector
|
||||||
|
implements ParlorCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs a parlor director and provides it with the parlor
|
* Constructs a parlor director and provides it with the parlor
|
||||||
@@ -90,8 +91,7 @@ public class ParlorDirector
|
|||||||
|
|
||||||
// generate the invocation service request
|
// generate the invocation service request
|
||||||
ParlorService.respond(_ctx.getClient(), invite.remoteId,
|
ParlorService.respond(_ctx.getClient(), invite.remoteId,
|
||||||
ParlorService.INVITATION_ACCEPTED,
|
INVITATION_ACCEPTED, null, this);
|
||||||
null, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,8 +114,7 @@ public class ParlorDirector
|
|||||||
|
|
||||||
// generate the invocation service request
|
// generate the invocation service request
|
||||||
ParlorService.respond(_ctx.getClient(), invite.remoteId,
|
ParlorService.respond(_ctx.getClient(), invite.remoteId,
|
||||||
ParlorService.INVITATION_REFUSED,
|
INVITATION_REFUSED, message, this);
|
||||||
message, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,8 +145,7 @@ public class ParlorDirector
|
|||||||
|
|
||||||
// generate the invocation service request
|
// generate the invocation service request
|
||||||
ParlorService.respond(_ctx.getClient(), invite.remoteId,
|
ParlorService.respond(_ctx.getClient(), invite.remoteId,
|
||||||
ParlorService.INVITATION_COUNTERED,
|
INVITATION_COUNTERED, config, this);
|
||||||
config, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,9 +218,9 @@ public class ParlorDirector
|
|||||||
*
|
*
|
||||||
* @param remoteId the unique indentifier for the invitation.
|
* @param remoteId the unique indentifier for the invitation.
|
||||||
* @param code the response code, either {@link
|
* @param code the response code, either {@link
|
||||||
* ParlorService#INVITATION_ACCEPTED} or {@link
|
* ParlorCodes#INVITATION_ACCEPTED} or {@link
|
||||||
* ParlorService#INVITATION_REFUSED} or {@link
|
* ParlorCodes#INVITATION_REFUSED} or {@link
|
||||||
* ParlorService#INVITATION_COUNTERED}.
|
* ParlorCodes#INVITATION_COUNTERED}.
|
||||||
* @param arg in the case of a refused invitation, a string
|
* @param arg in the case of a refused invitation, a string
|
||||||
* containing a message provided by the invited user explaining the
|
* containing a message provided by the invited user explaining the
|
||||||
* reason for refusal (the empty string if no explanation was
|
* reason for refusal (the empty string if no explanation was
|
||||||
@@ -251,16 +249,16 @@ public class ParlorDirector
|
|||||||
// notify the observer
|
// notify the observer
|
||||||
try {
|
try {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case ParlorService.INVITATION_ACCEPTED:
|
case INVITATION_ACCEPTED:
|
||||||
invite.observer.invitationAccepted(invite.inviteId);
|
invite.observer.invitationAccepted(invite.inviteId);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ParlorService.INVITATION_REFUSED:
|
case INVITATION_REFUSED:
|
||||||
invite.observer.invitationRefused(
|
invite.observer.invitationRefused(
|
||||||
invite.inviteId, (String)arg);
|
invite.inviteId, (String)arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ParlorService.INVITATION_COUNTERED:
|
case INVITATION_COUNTERED:
|
||||||
invite.observer.invitationCountered(
|
invite.observer.invitationCountered(
|
||||||
invite.inviteId, (GameConfig)arg);
|
invite.inviteId, (GameConfig)arg);
|
||||||
break;
|
break;
|
||||||
@@ -275,7 +273,7 @@ public class ParlorDirector
|
|||||||
|
|
||||||
// unless the invitation was countered, we can remove it from the
|
// unless the invitation was countered, we can remove it from the
|
||||||
// pending table because it's resolved
|
// pending table because it's resolved
|
||||||
if (code != ParlorService.INVITATION_COUNTERED) {
|
if (code != INVITATION_COUNTERED) {
|
||||||
_pendingInvites.remove(remoteId);
|
_pendingInvites.remove(remoteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ParlorService.java,v 1.3 2001/10/01 06:19:15 mdb Exp $
|
// $Id: ParlorService.java,v 1.4 2001/10/01 22:17:34 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.client;
|
package com.threerings.parlor.client;
|
||||||
|
|
||||||
@@ -19,32 +19,8 @@ import com.threerings.parlor.data.GameConfig;
|
|||||||
*
|
*
|
||||||
* @see ParlorDirector
|
* @see ParlorDirector
|
||||||
*/
|
*/
|
||||||
public class ParlorService
|
public class ParlorService implements ParlorCodes
|
||||||
{
|
{
|
||||||
/** The module name for the parlor services. */
|
|
||||||
public static final String MODULE = "parlor";
|
|
||||||
|
|
||||||
/** The message identifier for an invitation creation request or
|
|
||||||
* notification. */
|
|
||||||
public static final String INVITE_ID = "Invite";
|
|
||||||
|
|
||||||
/** The message identifier for an invitation cancellation request or
|
|
||||||
* notification. */
|
|
||||||
public static final String CANCEL_INVITE_ID = "CancelInvite";
|
|
||||||
|
|
||||||
/** The message identifier for an invitation response request or
|
|
||||||
* notification. */
|
|
||||||
public static final String RESPOND_INVITE_ID = "RespondInvite";
|
|
||||||
|
|
||||||
/** The response code for an accepted invitation. */
|
|
||||||
public static final int INVITATION_ACCEPTED = 0;
|
|
||||||
|
|
||||||
/** The response code for a refused invitation. */
|
|
||||||
public static final int INVITATION_REFUSED = 1;
|
|
||||||
|
|
||||||
/** The response code for a countered invitation. */
|
|
||||||
public static final int INVITATION_COUNTERED = 2;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You probably don't want to call this directly, but want to generate
|
* You probably don't want to call this directly, but want to generate
|
||||||
* your invitation request via {@link ParlorDirector#invite}. Requests
|
* your invitation request via {@link ParlorDirector#invite}. Requests
|
||||||
@@ -68,7 +44,7 @@ public class ParlorService
|
|||||||
Object[] args = new Object[] { invitee, config };
|
Object[] args = new Object[] { invitee, config };
|
||||||
Log.info("Sending invite request [to=" + invitee +
|
Log.info("Sending invite request [to=" + invitee +
|
||||||
", cfg=" + config + "].");
|
", cfg=" + config + "].");
|
||||||
return invmgr.invoke(MODULE, INVITE_ID, args, rsptarget);
|
return invmgr.invoke(MODULE_NAME, INVITE_ID, args, rsptarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +78,8 @@ public class ParlorService
|
|||||||
args[2] = (arg == null) ? "" : arg;
|
args[2] = (arg == null) ? "" : arg;
|
||||||
Log.info("Sending invitation response [inviteId=" + inviteId +
|
Log.info("Sending invitation response [inviteId=" + inviteId +
|
||||||
", code=" + code + ", arg=" + arg + "].");
|
", code=" + code + ", arg=" + arg + "].");
|
||||||
return invmgr.invoke(MODULE, RESPOND_INVITE_ID, args, rsptarget);
|
return invmgr.invoke(
|
||||||
|
MODULE_NAME, RESPOND_INVITE_ID, args, rsptarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,6 +101,6 @@ public class ParlorService
|
|||||||
Object[] args = new Object[] { new Integer(inviteId) };
|
Object[] args = new Object[] { new Integer(inviteId) };
|
||||||
Log.info("Sending invitation cancellation " +
|
Log.info("Sending invitation cancellation " +
|
||||||
"[inviteId=" + inviteId + "].");
|
"[inviteId=" + inviteId + "].");
|
||||||
return invmgr.invoke(MODULE, CANCEL_INVITE_ID, args, rsptarget);
|
return invmgr.invoke(MODULE_NAME, CANCEL_INVITE_ID, args, rsptarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: GameConfig.java,v 1.2 2001/10/01 06:19:15 mdb Exp $
|
// $Id: GameConfig.java,v 1.3 2001/10/01 22:17:34 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.data;
|
package com.threerings.parlor.data;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ import com.threerings.cocktail.cher.io.Streamable;
|
|||||||
* <p> The game config object is also the mechanism used to instantiate
|
* <p> The game config object is also the mechanism used to instantiate
|
||||||
* the appropriate game manager and controller. Every game must have an
|
* the appropriate game manager and controller. Every game must have an
|
||||||
* associated game config derived class that overrides {@link
|
* associated game config derived class that overrides {@link
|
||||||
* #getControllerClass} and {@link getManagerClassName}, returning the
|
* #getControllerClass} and {@link #getManagerClassName}, returning the
|
||||||
* appropriate game controller and manager class for that game. Thus the
|
* appropriate game controller and manager class for that game. Thus the
|
||||||
* entire chain of events that causes a particular game to be created is
|
* entire chain of events that causes a particular game to be created is
|
||||||
* the construction of the appropriate game config instance which is
|
* the construction of the appropriate game config instance which is
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
//
|
//
|
||||||
// $Id: ParlorManager.java,v 1.1 2001/10/01 02:56:35 mdb Exp $
|
// $Id: ParlorManager.java,v 1.2 2001/10/01 22:17:34 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.server;
|
package com.threerings.parlor.server;
|
||||||
|
|
||||||
import com.samskivert.util.Config;
|
import com.samskivert.util.Config;
|
||||||
|
|
||||||
import com.threerings.cocktail.cher.server.InvocationManager;
|
import com.threerings.cocktail.cher.server.InvocationManager;
|
||||||
import com.threerings.parlor.client.ParlorService;
|
import com.threerings.cocktail.party.data.BodyObject;
|
||||||
|
|
||||||
|
import com.threerings.parlor.client.ParlorCodes;
|
||||||
|
import com.threerings.parlor.data.GameConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parlor manager is responsible for the parlor services in
|
* The parlor manager is responsible for the parlor services in
|
||||||
@@ -16,6 +19,7 @@ import com.threerings.parlor.client.ParlorService;
|
|||||||
* game.
|
* game.
|
||||||
*/
|
*/
|
||||||
public class ParlorManager
|
public class ParlorManager
|
||||||
|
implements ParlorCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initializes the parlor manager. This should be called by the server
|
* Initializes the parlor manager. This should be called by the server
|
||||||
@@ -30,6 +34,25 @@ public class ParlorManager
|
|||||||
{
|
{
|
||||||
// register our invocation provider
|
// register our invocation provider
|
||||||
ParlorProvider pprov = new ParlorProvider(this);
|
ParlorProvider pprov = new ParlorProvider(this);
|
||||||
invmgr.registerProvider(ParlorService.MODULE, pprov);
|
invmgr.registerProvider(MODULE_NAME, pprov);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issues an invitation from the <code>inviter</code> to the
|
||||||
|
* <code>invitee</code> for a game as described by the supplied config
|
||||||
|
* object.
|
||||||
|
*
|
||||||
|
* @param inviter the player initiating the invitation.
|
||||||
|
* @param invitee the player being invited.
|
||||||
|
* @param config the configuration of the game being proposed.
|
||||||
|
*
|
||||||
|
* @return the <code>SUCCESS</code> constant if the invitation was
|
||||||
|
* accepted and delivered, or a string describing the reason for
|
||||||
|
* failure if it was rejected.
|
||||||
|
*/
|
||||||
|
public String invite (BodyObject inviter, BodyObject invitee,
|
||||||
|
GameConfig config)
|
||||||
|
{
|
||||||
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
//
|
//
|
||||||
// $Id: ParlorProvider.java,v 1.2 2001/10/01 05:07:13 mdb Exp $
|
// $Id: ParlorProvider.java,v 1.3 2001/10/01 22:17:34 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.server;
|
package com.threerings.parlor.server;
|
||||||
|
|
||||||
import com.threerings.cocktail.cher.server.InvocationProvider;
|
import com.threerings.cocktail.cher.server.InvocationProvider;
|
||||||
import com.threerings.cocktail.party.data.BodyObject;
|
import com.threerings.cocktail.party.data.BodyObject;
|
||||||
|
import com.threerings.cocktail.party.server.PartyServer;
|
||||||
|
|
||||||
|
import com.threerings.parlor.client.ParlorCodes;
|
||||||
import com.threerings.parlor.data.GameConfig;
|
import com.threerings.parlor.data.GameConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +15,8 @@ import com.threerings.parlor.data.GameConfig;
|
|||||||
* services that are made available for direct invocation by the client.
|
* services that are made available for direct invocation by the client.
|
||||||
* Primarily these are the matchmaking mechanisms.
|
* Primarily these are the matchmaking mechanisms.
|
||||||
*/
|
*/
|
||||||
public class ParlorProvider extends InvocationProvider
|
public class ParlorProvider
|
||||||
|
extends InvocationProvider implements ParlorCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs a parlor provider instance which will be used to handle
|
* Constructs a parlor provider instance which will be used to handle
|
||||||
@@ -36,6 +39,25 @@ public class ParlorProvider extends InvocationProvider
|
|||||||
public void handleInviteRequest (
|
public void handleInviteRequest (
|
||||||
BodyObject source, int invid, String invitee, GameConfig config)
|
BodyObject source, int invid, String invitee, GameConfig config)
|
||||||
{
|
{
|
||||||
|
String rsp = null;
|
||||||
|
|
||||||
|
// ensure that the invitee is online at present
|
||||||
|
BodyObject target = PartyServer.lookupBody(invitee);
|
||||||
|
if (target == null) {
|
||||||
|
rsp = "m.not_online\t" + invitee;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// if they are, submit the invite request to the parlor
|
||||||
|
// manager
|
||||||
|
rsp = _pmgr.invite(source, target, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now send the response
|
||||||
|
if (rsp.equals(SUCCESS)) {
|
||||||
|
sendResponse(source, invid, "InviteReceived");
|
||||||
|
} else {
|
||||||
|
sendResponse(source, invid, "InviteReceived");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user