com.threerings.parlor.client
Class ParlorDirector

java.lang.Object
  extended by com.threerings.presents.client.BasicDirector
      extended by com.threerings.parlor.client.ParlorDirector
All Implemented Interfaces:
ParlorReceiver, ParlorCodes, com.threerings.presents.client.InvocationReceiver, com.threerings.presents.client.SessionObserver, com.threerings.presents.data.InvocationCodes

public class ParlorDirector
extends com.threerings.presents.client.BasicDirector
implements ParlorCodes, ParlorReceiver

The parlor director manages the client side of the game configuration and matchmaking processes. It is also the entity that is listening for game start notifications which it then dispatches the client entity that will actually create and display the user interface for the game that started.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.presents.client.InvocationReceiver
com.threerings.presents.client.InvocationReceiver.Registration
 
Field Summary
 
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
ParlorDirector(ParlorContext ctx)
          Constructs a parlor director and provides it with the parlor context that it can use to access the client services that it needs to provide its own services.
 
Method Summary
 void addGameReadyObserver(GameReadyObserver observer)
          Adds the specified observer to the list of entities that are notified when we receive a game ready notification.
 void clientDidLogoff(com.threerings.presents.client.Client client)
           
 void gameIsReady(int gameOid)
          Dispatched to the client when a game in which they are a participant is ready for play.
 Invitation invite(com.threerings.util.Name invitee, GameConfig config, InvitationResponseObserver observer)
          Requests that the named user be invited to a game described by the supplied game config.
 void receivedInvite(int remoteId, com.threerings.util.Name inviter, GameConfig config)
          Called by the invocation services when another user has invited us to play a game.
 void receivedInviteCancellation(int remoteId)
          Called by the invocation services when an outstanding invitation has been cancelled by the inviting user.
 void receivedInviteResponse(int remoteId, int code, Object arg)
          Called by the invocation services when another user has responded to our invitation by either accepting, refusing or countering it.
 void removeGameReadyObserver(GameReadyObserver observer)
          Removes the specified observer from the list of entities that are notified when we receive a game ready notification.
 void setInvitationHandler(InvitationHandler handler)
          Sets the invitation handler, which is the entity that will be notified when we receive incoming invitation notifications and when invitations have been cancelled.
 void startSolitaire(GameConfig config, com.threerings.presents.client.InvocationService.ConfirmListener listener)
          Requests that the specified single player game be started.
 
Methods inherited from class com.threerings.presents.client.BasicDirector
clientDidLogon, clientObjectDidChange, clientWillLogon, isAvailableInStandalone, setAvailableInStandalone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParlorDirector

public ParlorDirector(ParlorContext ctx)
Constructs a parlor director and provides it with the parlor context that it can use to access the client services that it needs to provide its own services. Only one parlor director should be active in the client at one time and it should be made available via the parlor context.

Parameters:
ctx - the parlor context in use by the client.
Method Detail

setInvitationHandler

public void setInvitationHandler(InvitationHandler handler)
Sets the invitation handler, which is the entity that will be notified when we receive incoming invitation notifications and when invitations have been cancelled.

Parameters:
handler - our new invitation handler.

addGameReadyObserver

public void addGameReadyObserver(GameReadyObserver observer)
Adds the specified observer to the list of entities that are notified when we receive a game ready notification.


removeGameReadyObserver

public void removeGameReadyObserver(GameReadyObserver observer)
Removes the specified observer from the list of entities that are notified when we receive a game ready notification.


invite

public Invitation invite(com.threerings.util.Name invitee,
                         GameConfig config,
                         InvitationResponseObserver observer)
Requests that the named user be invited to a game described by the supplied game config.

Parameters:
invitee - the user to invite.
config - the configuration of the game to which the user is being invited.
observer - the entity that will be notified if this invitation is accepted, refused or countered.
Returns:
an invitation object that can be used to manage the outstanding invitation.

startSolitaire

public void startSolitaire(GameConfig config,
                           com.threerings.presents.client.InvocationService.ConfirmListener listener)
Requests that the specified single player game be started.

Parameters:
config - the configuration of the single player game to be started.
listener - a listener to be informed of failure if the game cannot be started.

clientDidLogoff

public void clientDidLogoff(com.threerings.presents.client.Client client)
Specified by:
clientDidLogoff in interface com.threerings.presents.client.SessionObserver
Overrides:
clientDidLogoff in class com.threerings.presents.client.BasicDirector

gameIsReady

public void gameIsReady(int gameOid)
Description copied from interface: ParlorReceiver
Dispatched to the client when a game in which they are a participant is ready for play. The client will then enter the game room which will trigger the loading of the appropriate game UI code and generally get things started.

Specified by:
gameIsReady in interface ParlorReceiver
Parameters:
gameOid - the object id of the game object.

receivedInvite

public void receivedInvite(int remoteId,
                           com.threerings.util.Name inviter,
                           GameConfig config)
Description copied from interface: ParlorReceiver
Called by the invocation services when another user has invited us to play a game.

Specified by:
receivedInvite in interface ParlorReceiver
Parameters:
remoteId - the unique indentifier for this invitation (used when countering or responding).
inviter - the username of the inviting user.
config - the configuration information for the game to which we've been invited.

receivedInviteResponse

public void receivedInviteResponse(int remoteId,
                                   int code,
                                   Object arg)
Description copied from interface: ParlorReceiver
Called by the invocation services when another user has responded to our invitation by either accepting, refusing or countering it.

Specified by:
receivedInviteResponse in interface ParlorReceiver
Parameters:
remoteId - the indentifier for the invitation on question.
code - the response code, either ParlorCodes.INVITATION_ACCEPTED or ParlorCodes.INVITATION_REFUSED or ParlorCodes.INVITATION_COUNTERED.
arg - in the case of a refused invitation, a string containing a message provided by the invited user explaining the reason for refusal (the empty string if no explanation was provided). In the case of a countered invitation, a new game config object with the modified game configuration.

receivedInviteCancellation

public void receivedInviteCancellation(int remoteId)
Description copied from interface: ParlorReceiver
Called by the invocation services when an outstanding invitation has been cancelled by the inviting user.

Specified by:
receivedInviteCancellation in interface ParlorReceiver
Parameters:
remoteId - the indentifier of the cancelled invitation.


Copyright © 2011. All Rights Reserved.