From 57faa7f72e604deab2a645ba92ccf1f0b84dd251 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Tue, 28 Apr 2009 02:15:15 +0000 Subject: [PATCH] User identification on the client. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@818 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../parlor/game/client/GameController.as | 21 +++++++++++++++++++ .../parlor/game/data/UserIdentifier.as | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/as/com/threerings/parlor/game/client/GameController.as b/src/as/com/threerings/parlor/game/client/GameController.as index 39cd330e..1f78f04b 100644 --- a/src/as/com/threerings/parlor/game/client/GameController.as +++ b/src/as/com/threerings/parlor/game/client/GameController.as @@ -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; } } diff --git a/src/as/com/threerings/parlor/game/data/UserIdentifier.as b/src/as/com/threerings/parlor/game/data/UserIdentifier.as index 4fdbd664..d0e790f3 100644 --- a/src/as/com/threerings/parlor/game/data/UserIdentifier.as +++ b/src/as/com/threerings/parlor/game/data/UserIdentifier.as @@ -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; } }