More over the wire class dependency noting.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@602 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2008-05-22 15:35:37 +00:00
parent ae6c542271
commit 55d16fc0c9
3 changed files with 58 additions and 64 deletions
@@ -33,25 +33,24 @@ import com.threerings.presents.client.InvocationService;
import com.threerings.presents.client.InvocationService_ConfirmListener; import com.threerings.presents.client.InvocationService_ConfirmListener;
import com.threerings.parlor.data.ParlorCodes; import com.threerings.parlor.data.ParlorCodes;
import com.threerings.parlor.data.ParlorMarshaller;
import com.threerings.parlor.game.data.GameConfig; import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.util.ParlorContext;
/** /**
* The parlor director manages the client side of the game configuration * The parlor director manages the client side of the game configuration and matchmaking processes.
* and matchmaking processes. It is also the entity that is listening for * It is also the entity that is listening for game start notifications which it then dispatches
* game start notifications which it then dispatches the client entity * the client entity that will actually create and display the user interface for the game that
* that will actually create and display the user interface for the game * started.
* that started.
*/ */
public class ParlorDirector extends BasicDirector public class ParlorDirector extends BasicDirector
implements ParlorReceiver implements ParlorReceiver
{ {
/** /**
* Constructs a parlor director and provides it with the parlor * Constructs a parlor director and provides it with the parlor context that it can use to
* context that it can use to access the client services that it needs * access the client services that it needs to provide its own services. Only one parlor
* to provide its own services. Only one parlor director should be * director should be active in the client at one time and it should be made available via the
* active in the client at one time and it should be made available * parlor context.
* via the parlor context.
* *
* @param ctx the parlor context in use by the client. * @param ctx the parlor context in use by the client.
*/ */
@@ -60,16 +59,16 @@ public class ParlorDirector extends BasicDirector
super(ctx); super(ctx);
_pctx = ctx; _pctx = ctx;
// register ourselves with the invocation director as a parlor // register ourselves with the invocation director as a parlor notification receiver
// notification receiver _pctx.getClient().getInvocationDirector().registerReceiver(new ParlorDecoder(this));
_pctx.getClient().getInvocationDirector().registerReceiver(
new ParlorDecoder(this)); // ensure that the compiler includes these necessary symbols
var c :Class = ParlorMarshaller;
} }
/** /**
* Sets the invitation handler, which is the entity that will be * Sets the invitation handler, which is the entity that will be notified when we receive
* notified when we receive incoming invitation notifications and when * incoming invitation notifications and when invitations have been cancelled.
* invitations have been cancelled.
* *
* @param handler our new invitation handler. * @param handler our new invitation handler.
*/ */
@@ -79,8 +78,8 @@ public class ParlorDirector extends BasicDirector
} }
/** /**
* Adds the specified observer to the list of entities that are * Adds the specified observer to the list of entities that are notified when we receive a game
* notified when we receive a game ready notification. * ready notification.
*/ */
public function addGameReadyObserver (observer :GameReadyObserver) :void public function addGameReadyObserver (observer :GameReadyObserver) :void
{ {
@@ -88,8 +87,8 @@ public class ParlorDirector extends BasicDirector
} }
/** /**
* Removes the specified observer from the list of entities that are * Removes the specified observer from the list of entities that are notified when we receive a
* notified when we receive a game ready notification. * game ready notification.
*/ */
public function removeGameReadyObserver (observer :GameReadyObserver) :void public function removeGameReadyObserver (observer :GameReadyObserver) :void
{ {
@@ -97,25 +96,20 @@ public class ParlorDirector extends BasicDirector
} }
/** /**
* Requests that the named user be invited to a game described by the * Requests that the named user be invited to a game described by the supplied game config.
* supplied game config.
* *
* @param invitee the user to invite. * @param invitee the user to invite.
* @param config the configuration of the game to which the user is * @param config the configuration of the game to which the user is being invited.
* being invited. * @param observer the entity that will be notified if this invitation is accepted, refused or
* @param observer the entity that will be notified if this invitation * countered.
* is accepted, refused or countered.
* *
* @return an invitation object that can be used to manage the * @return an invitation object that can be used to manage the outstanding invitation.
* outstanding invitation.
*/ */
public function invite ( public function invite (
invitee :Name, config :GameConfig, invitee :Name, config :GameConfig, observer :InvitationResponseObserver) :Invitation
observer :InvitationResponseObserver) :Invitation
{ {
// create the invitation record // create the invitation record
var invite :Invitation = new Invitation( var invite :Invitation = new Invitation(_pctx, _pservice, invitee, config, observer);
_pctx, _pservice, invitee, config, observer);
// submit the invitation request to the server // submit the invitation request to the server
_pservice.invite(_pctx.getClient(), invitee, config, invite); _pservice.invite(_pctx.getClient(), invitee, config, invite);
// and return the invitation to the caller // and return the invitation to the caller
@@ -125,10 +119,8 @@ public class ParlorDirector extends BasicDirector
/** /**
* Requests that the specified single player game be started. * Requests that the specified single player game be started.
* *
* @param config the configuration of the single player game to be * @param config the configuration of the single player game to be started.
* started. * @param listener a listener to be informed of failure if the game cannot be started.
* @param listener a listener to be informed of failure if the game
* cannot be started.
*/ */
public function startSolitaire ( public function startSolitaire (
config :GameConfig, listener :InvocationService_ConfirmListener) :void config :GameConfig, listener :InvocationService_ConfirmListener) :void
@@ -147,7 +139,7 @@ public class ParlorDirector extends BasicDirector
// documentation inherited from interface // documentation inherited from interface
public function gameIsReady (gameOid :int) :void public function gameIsReady (gameOid :int) :void
{ {
Log.getLog(this).info("Handling game ready [goid=" + gameOid + "]."); _log.info("Handling game ready [goid=" + gameOid + "].");
// see what our observers have to say about it // see what our observers have to say about it
var handled :Boolean = false; var handled :Boolean = false;
@@ -156,20 +148,18 @@ public class ParlorDirector extends BasicDirector
handled = grob.receivedGameReady(gameOid) || handled; handled = grob.receivedGameReady(gameOid) || handled;
} }
// if none of the observers took matters into their own hands, // if none of the observers took matters into their own hands, then we'll head on over to
// then we'll head on over to the game room ourselves // the game room ourselves
if (!handled) { if (!handled) {
_pctx.getLocationDirector().moveTo(gameOid); _pctx.getLocationDirector().moveTo(gameOid);
} }
} }
// documentation inherited from interface // documentation inherited from interface
public function receivedInvite ( public function receivedInvite (remoteId :int, inviter :Name, config :GameConfig) :void
remoteId :int, inviter :Name, config :GameConfig) :void
{ {
// create an invitation record for this invitation // create an invitation record for this invitation
var invite :Invitation = new Invitation( var invite :Invitation = new Invitation(_pctx, _pservice, inviter, config, null);
_pctx, _pservice, inviter, config, null);
invite.inviteId = remoteId; invite.inviteId = remoteId;
// put it in the pending invitations table // put it in the pending invitations table
@@ -180,24 +170,19 @@ public class ParlorDirector extends BasicDirector
_handler.invitationReceived(invite); _handler.invitationReceived(invite);
} catch (err :Error) { } catch (err :Error) {
var log :Log = Log.getLog(this); _log.warning("Invitation handler choked on invite notification " + invite + ".");
log.warning("Invitation handler choked on invite " + _log.logStackTrace(err);
"notification " + invite + ".");
log.logStackTrace(err);
} }
} }
// documentation inherited from interface // documentation inherited from interface
public function receivedInviteResponse ( public function receivedInviteResponse (remoteId :int, code :int, arg :Object) :void
remoteId :int, code :int, arg :Object) :void
{ {
// look up the invitation record for this invitation // look up the invitation record for this invitation
var invite :Invitation = (_pendingInvites.get(remoteId) as Invitation); var invite :Invitation = (_pendingInvites.get(remoteId) as Invitation);
if (invite == null) { if (invite == null) {
Log.getLog(this).warning("Have no record of invitation for " + _log.warning("Have no record of invitation for which we received a response?! " +
"which we received a response?! [remoteId=" + remoteId + "[remoteId=" + remoteId + ", code=" + code + ", arg=" + arg + "].");
", code=" + code + ", arg=" + arg + "].");
} else { } else {
invite.receivedResponse(code, arg); invite.receivedResponse(code, arg);
} }
@@ -210,8 +195,8 @@ public class ParlorDirector extends BasicDirector
} }
/** /**
* Register a new invitation in our pending invitations table. The * Register a new invitation in our pending invitations table. The invitation will call this
* invitation will call this when it knows its invitation id. * when it knows its invitation id.
*/ */
public function registerInvitation (invite :Invitation) :void public function registerInvitation (invite :Invitation) :void
{ {
@@ -219,8 +204,8 @@ public class ParlorDirector extends BasicDirector
} }
/** /**
* Called by an invitation when it knows it is no longer and can be * Called by an invitation when it knows it is no longer and can be cleared from the pending
* cleared from the pending invitations table. * invitations table.
*/ */
public function clearInvitation (invite :Invitation) :void public function clearInvitation (invite :Invitation) :void
{ {
@@ -247,16 +232,17 @@ public class ParlorDirector extends BasicDirector
/** Provides access to parlor server side services. */ /** Provides access to parlor server side services. */
protected var _pservice :ParlorService; protected var _pservice :ParlorService;
/** The entity that has registered itself to handle incoming /** The entity that has registered itself to handle incoming invitation notifications. */
* invitation notifications. */
protected var _handler :InvitationHandler; protected var _handler :InvitationHandler;
/** A table of acknowledged (but not yet accepted or refused) /** A table of acknowledged (but not yet accepted or refused) invitation requests, keyed on
* invitation requests, keyed on invitation id. */ * invitation id. */
protected var _pendingInvites :HashMap = new HashMap(); protected var _pendingInvites :HashMap = new HashMap();
/** We notify the entities on this list when we get a game ready /** We notify the entities on this list when we get a game ready notification. */
* notification. */
protected var _grobs :Array = new Array(); protected var _grobs :Array = new Array();
/** For great logging. */
private var _log :Log = Log.getLog(this);
} }
} }
@@ -45,6 +45,7 @@ import com.threerings.crowd.data.PlaceObject;
import com.threerings.whirled.client.persist.SceneRepository; import com.threerings.whirled.client.persist.SceneRepository;
import com.threerings.whirled.data.Scene; import com.threerings.whirled.data.Scene;
import com.threerings.whirled.data.SceneCodes; import com.threerings.whirled.data.SceneCodes;
import com.threerings.whirled.data.SceneMarshaller;
import com.threerings.whirled.data.SceneModel; import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.data.SceneObject; import com.threerings.whirled.data.SceneObject;
import com.threerings.whirled.data.SceneUpdate; import com.threerings.whirled.data.SceneUpdate;
@@ -100,6 +101,9 @@ public class SceneDirector extends BasicDirector
// register for scene notifications // register for scene notifications
_wctx.getClient().getInvocationDirector().registerReceiver(new SceneDecoder(this)); _wctx.getClient().getInvocationDirector().registerReceiver(new SceneDecoder(this));
// ensure that the compiler includes these necessary symbols
var c :Class = SceneMarshaller;
} }
/** /**
@@ -53,6 +53,7 @@ import com.threerings.whirled.spot.data.Location;
import com.threerings.whirled.spot.data.Portal; import com.threerings.whirled.spot.data.Portal;
import com.threerings.whirled.spot.data.SceneLocation; import com.threerings.whirled.spot.data.SceneLocation;
import com.threerings.whirled.spot.data.SpotCodes; import com.threerings.whirled.spot.data.SpotCodes;
import com.threerings.whirled.spot.data.SpotMarshaller;
import com.threerings.whirled.spot.data.SpotScene; import com.threerings.whirled.spot.data.SpotScene;
import com.threerings.whirled.spot.data.SpotSceneObject; import com.threerings.whirled.spot.data.SpotSceneObject;
@@ -82,6 +83,9 @@ public class SpotSceneDirector extends BasicDirector
// wire ourselves up to hear about leave place notifications // wire ourselves up to hear about leave place notifications
locdir.addLocationObserver(new LocationAdapter(null, handleSceneChange, null)); locdir.addLocationObserver(new LocationAdapter(null, handleSceneChange, null));
// ensure that the compiler includes these necessary symbols
var c :Class = SpotMarshaller;
} }
/** /**