Updates to EZGame to allow games to store 'user cookies'.
Then intention is that other games besides EZGame may use this as well, so it's semi-separated, but for now it's part of EZGame. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@123 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
package com.threerings.ezgame.data {
|
||||
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DSet_Entry;
|
||||
|
||||
import com.threerings.ezgame.util.EZObjectMarshaller;
|
||||
|
||||
public class UserCookie
|
||||
implements DSet_Entry
|
||||
{
|
||||
/** The index of the player that has this cookie. */
|
||||
public var playerIndex :int;
|
||||
|
||||
/** The decoded cookie value. */
|
||||
public var cookie :Object;
|
||||
|
||||
// from DSet_Entry
|
||||
public function getKey () :Object
|
||||
{
|
||||
return playerIndex;
|
||||
}
|
||||
|
||||
// from superinterface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
playerIndex = ins.readInt();
|
||||
var ba :ByteArray = (ins.readObject() as ByteArray);
|
||||
cookie = EZObjectMarshaller.decode(ba);
|
||||
}
|
||||
|
||||
// from superinterface Streamable
|
||||
public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user