Added facilities for being notified when the parlor director receives a
game ready notification and for taking charge of the process of entering the game room. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@980 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// $Id: GameReadyObserver.java,v 1.1 2002/02/09 11:23:49 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.parlor.client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to inform interested parties when the {@link ParlorDirector}
|
||||||
|
* receives a game ready notification. The observers can ratify the
|
||||||
|
* decision to head directly into the game or can take responsibility
|
||||||
|
* themselves for doing so.
|
||||||
|
*/
|
||||||
|
public interface GameReadyObserver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Called when a game ready notification is received.
|
||||||
|
*
|
||||||
|
* @param gameOid the place oid of the ready game.
|
||||||
|
*
|
||||||
|
* @return if the observer returns true from this method, the parlor
|
||||||
|
* director assumes they will take care of entering the game room
|
||||||
|
* after performing processing of their own. If all observers return
|
||||||
|
* false, the director will enter the game room automatically.
|
||||||
|
*/
|
||||||
|
public boolean receivedGameReady (int gameOid);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ParlorDirector.java,v 1.13 2001/10/23 02:22:16 mdb Exp $
|
// $Id: ParlorDirector.java,v 1.14 2002/02/09 11:23:49 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.parlor.client;
|
package com.threerings.parlor.client;
|
||||||
|
|
||||||
@@ -54,6 +54,24 @@ public class ParlorDirector
|
|||||||
_handler = handler;
|
_handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified observer to the list of entities that are
|
||||||
|
* notified when we receive a game ready notification.
|
||||||
|
*/
|
||||||
|
public void addGameReadyObserver (GameReadyObserver observer)
|
||||||
|
{
|
||||||
|
_grobs.add(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the specified observer from the list of entities that are
|
||||||
|
* notified when we receive a game ready notification.
|
||||||
|
*/
|
||||||
|
public void removeGameReadyObserver (GameReadyObserver observer)
|
||||||
|
{
|
||||||
|
_grobs.remove(observer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@@ -196,8 +214,18 @@ public class ParlorDirector
|
|||||||
{
|
{
|
||||||
Log.info("Handling game ready [goid=" + gameOid + "].");
|
Log.info("Handling game ready [goid=" + gameOid + "].");
|
||||||
|
|
||||||
// go there
|
// see what our observers have to say about it
|
||||||
_ctx.getLocationDirector().moveTo(gameOid);
|
boolean handled = false;
|
||||||
|
for (int i = 0; i < _grobs.size(); i++) {
|
||||||
|
GameReadyObserver grob = (GameReadyObserver)_grobs.get(i);
|
||||||
|
handled = grob.receivedGameReady(gameOid) || handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if none of the observers took matters into their own hands,
|
||||||
|
// then we'll head on over to the game room ourselves
|
||||||
|
if (!handled) {
|
||||||
|
_ctx.getLocationDirector().moveTo(gameOid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -476,4 +504,8 @@ public class ParlorDirector
|
|||||||
|
|
||||||
/** A counter used to assign a unique id to every invitation. */
|
/** A counter used to assign a unique id to every invitation. */
|
||||||
protected static int _localInvitationId = 0;
|
protected static int _localInvitationId = 0;
|
||||||
|
|
||||||
|
/** We notify the entities on this list when we get a game ready
|
||||||
|
* notification. */
|
||||||
|
protected ArrayList _grobs = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user