com.threerings.parlor.server
Class ParlorManager

java.lang.Object
  extended by com.threerings.parlor.server.ParlorManager
All Implemented Interfaces:
ParlorCodes, ParlorProvider, InvocationCodes, InvocationProvider

public class ParlorManager
extends Object
implements ParlorCodes, ParlorProvider

The parlor manager is responsible for the parlor services in aggregate. This includes maintaining the registry of active games, handling the necessary coordination for the matchmaking services and anything else that falls outside the scope of an actual in-progress game.


Nested Class Summary
protected static class ParlorManager.Invitation
          The invitation record is used by the parlor manager to keep track of pending invitations.
 
Field Summary
protected  IntMap<ParlorManager.Invitation> _invites
          The table of pending invitations.
protected  BodyLocator _locator
          Used to look body objects up by name.
protected static int _nextInviteId
          A counter used to generate unique identifiers for invitation records.
protected  PlaceRegistry _plreg
          The place registry with which we operate.
 
Fields inherited from interface com.threerings.parlor.data.ParlorCodes
ALREADY_AT_TABLE, BANNED_FROM_TABLE, GAME_ALREADY_STARTED, INVALID_TABLE_POSITION, INVITATION_ACCEPTED, INVITATION_COUNTERED, INVITATION_REFUSED, INVITEE_NOT_ONLINE, MUST_BE_CREATOR, NO_SELF_BOOT, NO_SUCH_TABLE, NOT_AT_TABLE, PARLOR_GROUP, TABLE_POSITION_OCCUPIED
 
Fields inherited from interface com.threerings.presents.data.InvocationCodes
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR
 
Constructor Summary
ParlorManager(InvocationManager invmgr)
           
 
Method Summary
 void cancel(ClientObject caller, int inviteId, InvocationService.InvocationListener listener)
          Handles a ParlorService.cancel(int, com.threerings.presents.client.InvocationService.InvocationListener) request.
 void cancelInvite(BodyObject source, int inviteId)
          Requests that an outstanding invitation be cancelled.
protected  void createGameManager(GameConfig config)
          Called to create our game managers.
 int invite(BodyObject inviter, BodyObject invitee, GameConfig config)
          Issues an invitation from the inviter to the invitee for a game as described by the supplied config object.
 void invite(ClientObject caller, Name invitee, GameConfig config, ParlorService.InviteListener listener)
          Handles a ParlorService.invite(com.threerings.util.Name, com.threerings.parlor.game.data.GameConfig, com.threerings.parlor.client.ParlorService.InviteListener) request.
protected  void processAcceptedInvitation(ParlorManager.Invitation invite)
          Starts up and configures the game manager for an accepted invitation.
 void respond(ClientObject caller, int inviteId, int code, Object arg, InvocationService.InvocationListener listener)
          Handles a ParlorService.respond(int, int, java.lang.Object, com.threerings.presents.client.InvocationService.InvocationListener) request.
 void respondToInvite(BodyObject source, int inviteId, int code, Object arg)
          Effects a response to an invitation (accept, refuse or counter), made by the specified source user with the specified arguments.
 void startSolitaire(ClientObject caller, GameConfig config, InvocationService.ConfirmListener listener)
          Handles a ParlorService.startSolitaire(com.threerings.parlor.game.data.GameConfig, com.threerings.presents.client.InvocationService.ConfirmListener) request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_plreg

@Inject
protected PlaceRegistry _plreg
The place registry with which we operate.


_locator

@Inject
protected BodyLocator _locator
Used to look body objects up by name.


_invites

protected IntMap<ParlorManager.Invitation> _invites
The table of pending invitations.


_nextInviteId

protected static int _nextInviteId
A counter used to generate unique identifiers for invitation records.

Constructor Detail

ParlorManager

@Inject
public ParlorManager(InvocationManager invmgr)
Method Detail

invite

public void invite(ClientObject caller,
                   Name invitee,
                   GameConfig config,
                   ParlorService.InviteListener listener)
            throws InvocationException
Description copied from interface: ParlorProvider
Handles a ParlorService.invite(com.threerings.util.Name, com.threerings.parlor.game.data.GameConfig, com.threerings.parlor.client.ParlorService.InviteListener) request.

Specified by:
invite in interface ParlorProvider
Throws:
InvocationException

respond

public void respond(ClientObject caller,
                    int inviteId,
                    int code,
                    Object arg,
                    InvocationService.InvocationListener listener)
Description copied from interface: ParlorProvider
Handles a ParlorService.respond(int, int, java.lang.Object, com.threerings.presents.client.InvocationService.InvocationListener) request.

Specified by:
respond in interface ParlorProvider

cancel

public void cancel(ClientObject caller,
                   int inviteId,
                   InvocationService.InvocationListener listener)
Description copied from interface: ParlorProvider
Handles a ParlorService.cancel(int, com.threerings.presents.client.InvocationService.InvocationListener) request.

Specified by:
cancel in interface ParlorProvider

startSolitaire

public void startSolitaire(ClientObject caller,
                           GameConfig config,
                           InvocationService.ConfirmListener listener)
                    throws InvocationException
Description copied from interface: ParlorProvider
Handles a ParlorService.startSolitaire(com.threerings.parlor.game.data.GameConfig, com.threerings.presents.client.InvocationService.ConfirmListener) request.

Specified by:
startSolitaire in interface ParlorProvider
Throws:
InvocationException

invite

public int invite(BodyObject inviter,
                  BodyObject invitee,
                  GameConfig config)
           throws InvocationException
Issues an invitation from the inviter to the invitee for a game as described by the supplied config object.

Parameters:
inviter - the player initiating the invitation.
invitee - the player being invited.
config - the configuration of the game being proposed.
Returns:
the invitation identifier for the newly created invitation record.
Throws:
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.

respondToInvite

public void respondToInvite(BodyObject source,
                            int inviteId,
                            int code,
                            Object arg)
Effects a response to an invitation (accept, refuse or counter), made by the specified source user with the specified arguments.

Parameters:
source - the body object of the user that is issuing this response.
inviteId - the identifier of the invitation to which we are responding.
code - the response code (either ParlorCodes.INVITATION_ACCEPTED, ParlorCodes.INVITATION_REFUSED or ParlorCodes.INVITATION_COUNTERED).
arg - the argument that goes along with the response: an explanatory message in the case of a refusal (the empty string, not null, if no message was provided) or the new game configuration in the case of a counter-invitation.

cancelInvite

public void cancelInvite(BodyObject source,
                         int inviteId)
Requests that an outstanding invitation be cancelled.

Parameters:
source - the body object of the user that is making the request.
inviteId - the unique id of the invitation to be cancelled.

processAcceptedInvitation

protected void processAcceptedInvitation(ParlorManager.Invitation invite)
Starts up and configures the game manager for an accepted invitation.


createGameManager

protected void createGameManager(GameConfig config)
                          throws InstantiationException,
                                 InvocationException
Called to create our game managers.

Throws:
InstantiationException
InvocationException