Move UserIdentifier up to GameManager where it can be used by other services.
Revamped the way the GameCookieManager does its business. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@346 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -67,6 +67,26 @@ import com.threerings.util.MessageBundle;
|
||||
public class GameManager extends PlaceManager
|
||||
implements ParlorCodes, GameCodes
|
||||
{
|
||||
/**
|
||||
* An interface for identifying users. A larger system using the Parlor game services can
|
||||
* enable user identification by passing a UserIdentifier to {@link #setUserIdentifier}.
|
||||
*/
|
||||
public interface UserIdentifier
|
||||
{
|
||||
/** Returns the persistent user id for the specified player, or 0 if they're not a valid
|
||||
* user, or a guest, or something like that (for whom we'll track no persistent data). */
|
||||
public int getUserId (BodyObject bodyObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a means by which the Parlor game services can map users to a persistent user id
|
||||
* for things like per-game cookies and ratings.
|
||||
*/
|
||||
public static void setUserIdentifier (UserIdentifier userIder)
|
||||
{
|
||||
_userIder = userIder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration object for the game being managed by this manager.
|
||||
*/
|
||||
@@ -310,6 +330,14 @@ public class GameManager extends PlaceManager
|
||||
return (_playerOids == null) ? -1 : _playerOids[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the persistent user id for the supplied body.
|
||||
*/
|
||||
public int getPlayerPersistentId (BodyObject bobj)
|
||||
{
|
||||
return (bobj == null) ? 0 : _userIder.getUserId(bobj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of players in the game.
|
||||
*/
|
||||
@@ -1279,6 +1307,13 @@ public class GameManager extends PlaceManager
|
||||
/** The interval for the game manager tick. */
|
||||
protected static Interval _tickInterval;
|
||||
|
||||
/** Used to map users to persistent integer identifiers. */
|
||||
protected static UserIdentifier _userIder = new UserIdentifier() {
|
||||
public int getUserId (BodyObject bodyObj) {
|
||||
return 0; // by default no one has persistent info
|
||||
}
|
||||
};
|
||||
|
||||
/** We give players 30 seconds to turn up in a game; after that, they're considered a no
|
||||
* show. */
|
||||
protected static final long NOSHOW_DELAY = 30 * 1000L;
|
||||
|
||||
Reference in New Issue
Block a user