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:
Michael Bayne
2001-10-01 22:17:34 +00:00
parent 64bed2eb12
commit a2f4a2cb7a
6 changed files with 106 additions and 50 deletions
@@ -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;
import com.samskivert.util.Config;
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
@@ -16,6 +19,7 @@ import com.threerings.parlor.client.ParlorService;
* game.
*/
public class ParlorManager
implements ParlorCodes
{
/**
* Initializes the parlor manager. This should be called by the server
@@ -30,6 +34,25 @@ public class ParlorManager
{
// register our invocation provider
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;
import com.threerings.cocktail.cher.server.InvocationProvider;
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;
/**
@@ -13,7 +15,8 @@ import com.threerings.parlor.data.GameConfig;
* services that are made available for direct invocation by the client.
* 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
@@ -36,6 +39,25 @@ public class ParlorProvider extends InvocationProvider
public void handleInviteRequest (
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");
}
}
/**