User identification on the client.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@818 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Ray Greenwell
2009-04-28 02:15:15 +00:00
parent 9a398a955c
commit 57faa7f72e
2 changed files with 23 additions and 2 deletions
@@ -22,6 +22,7 @@
package com.threerings.parlor.game.client {
import com.threerings.util.Log;
import com.threerings.util.Name;
import com.threerings.presents.dobj.AttributeChangeListener;
import com.threerings.presents.dobj.AttributeChangedEvent;
@@ -35,6 +36,7 @@ import com.threerings.crowd.util.CrowdContext;
import com.threerings.parlor.game.data.GameCodes;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.game.data.GameObject;
import com.threerings.parlor.game.data.UserIdentifier;
import com.threerings.parlor.util.ParlorContext;
/**
@@ -52,6 +54,14 @@ public /*abstract*/ class GameController extends PlaceController
{
protected static const log :Log = Log.getLog(GameController);
/**
* Configures a means for identifying users persistently.
*/
public static function setUserIdentifier (userIder :UserIdentifier) :void
{
_userIder = userIder;
}
/**
* Initializes this game controller with the game configuration that
* was established during the match making process. Derived classes
@@ -159,6 +169,14 @@ public /*abstract*/ class GameController extends PlaceController
setGameOver(true);
}
/**
* Returns the persistent user id for the supplied player name.
*/
public function getPlayerPersistentId (name :Name) :int
{
return (_userIder == null) ? 0 : _userIder.getUserId(name);
}
/**
* Returns the unique identifier for the current gameplay session.
*/
@@ -321,5 +339,8 @@ public /*abstract*/ class GameController extends PlaceController
* the client knows the game is over before the server has
* transitioned the game object accordingly. */
protected var _gameOver :Boolean;
/** Used to map users to persistent integer identifiers. */
protected static var _userIder :UserIdentifier;
}
}
@@ -3,13 +3,13 @@
package com.threerings.parlor.game.data {
import com.threerings.crowd.data.BodyObject;
import com.threerings.util.Name;
public interface UserIdentifier
{
/**
* Returns the id of the specified user, or 0 if they're not valid.
*/
function getUserId (bodyObj :BodyObject) :int;
function getUserId (name :Name) :int;
}
}