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:
Ray Greenwell
2006-11-15 03:01:49 +00:00
parent a4ae0dd2dc
commit cff4238b3e
19 changed files with 857 additions and 13 deletions
@@ -29,6 +29,10 @@ public class EZGameConfig extends GameConfig
// For now, the configData is either a classname or url.
public var configData :String;
/** If non-zero, a game id used to persistently identify the game.
* This could be thought of as a new-style rating id. */
public var persistentGameId:int;
public function EZGameConfig ()
{
// nothing needed
@@ -89,6 +93,7 @@ public class EZGameConfig extends GameConfig
super.readObject(ins);
configData = (ins.readField(String) as String);
persistentGameId = ins.readInt();
}
// from interface Streamable
@@ -97,6 +102,7 @@ public class EZGameConfig extends GameConfig
super.writeObject(out);
out.writeField(configData);
out.writeInt(persistentGameId);
}
}
}
@@ -21,6 +21,7 @@
package com.threerings.ezgame.data {
import flash.utils.ByteArray;
import com.threerings.util.*; // for Float, Integer, etc.
import com.threerings.ezgame.client.EZGameService;
@@ -80,8 +81,21 @@ public class EZGameMarshaller extends InvocationMarshaller
]);
}
/** The method id used to dispatch {@link #getCookie} requests. */
public static const GET_COOKIE :int = 4;
// from interface EZGameService
public function getCookie (arg1 :Client, arg2 :int, arg3 :InvocationService_InvocationListener) :void
{
var listener3 :InvocationMarshaller_ListenerMarshaller = new InvocationMarshaller_ListenerMarshaller();
listener3.listener = arg3;
sendRequest(arg1, GET_COOKIE, [
Integer.valueOf(arg2), listener3
]);
}
/** The method id used to dispatch {@link #getFromCollection} requests. */
public static const GET_FROM_COLLECTION :int = 4;
public static const GET_FROM_COLLECTION :int = 5;
// from interface EZGameService
public function getFromCollection (arg1 :Client, arg2 :String, arg3 :Boolean, arg4 :int, arg5 :String, arg6 :int, arg7 :InvocationService_ConfirmListener) :void
@@ -94,7 +108,7 @@ public class EZGameMarshaller extends InvocationMarshaller
}
/** The method id used to dispatch {@link #mergeCollection} requests. */
public static const MERGE_COLLECTION :int = 5;
public static const MERGE_COLLECTION :int = 6;
// from interface EZGameService
public function mergeCollection (arg1 :Client, arg2 :String, arg3 :String, arg4 :InvocationService_InvocationListener) :void
@@ -107,7 +121,7 @@ public class EZGameMarshaller extends InvocationMarshaller
}
/** The method id used to dispatch {@link #sendMessage} requests. */
public static const SEND_MESSAGE :int = 6;
public static const SEND_MESSAGE :int = 7;
// from interface EZGameService
public function sendMessage (arg1 :Client, arg2 :String, arg3 :Object, arg4 :int, arg5 :InvocationService_InvocationListener) :void
@@ -119,8 +133,21 @@ public class EZGameMarshaller extends InvocationMarshaller
]);
}
/** The method id used to dispatch {@link #setCookie} requests. */
public static const SET_COOKIE :int = 8;
// from interface EZGameService
public function setCookie (arg1 :Client, arg2 :ByteArray, arg3 :InvocationService_InvocationListener) :void
{
var listener3 :InvocationMarshaller_ListenerMarshaller = new InvocationMarshaller_ListenerMarshaller();
listener3.listener = arg3;
sendRequest(arg1, SET_COOKIE, [
arg2, listener3
]);
}
/** The method id used to dispatch {@link #setProperty} requests. */
public static const SET_PROPERTY :int = 7;
public static const SET_PROPERTY :int = 9;
// from interface EZGameService
public function setProperty (arg1 :Client, arg2 :String, arg3 :Object, arg4 :int, arg5 :InvocationService_InvocationListener) :void
@@ -133,7 +160,7 @@ public class EZGameMarshaller extends InvocationMarshaller
}
/** The method id used to dispatch {@link #setTicker} requests. */
public static const SET_TICKER :int = 8;
public static const SET_TICKER :int = 10;
// from interface EZGameService
public function setTicker (arg1 :Client, arg2 :String, arg3 :int, arg4 :InvocationService_InvocationListener) :void
@@ -10,6 +10,8 @@ import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.TypedArray;
import com.threerings.presents.dobj.DSet;
import com.threerings.parlor.game.data.GameObject;
import com.threerings.parlor.turn.data.TurnGameObject;
@@ -31,6 +33,9 @@ public class EZGameObject extends GameObject
/** The field name of the <code>turnHolder</code> field. */
public static const TURN_HOLDER :String = "turnHolder";
/** The field name of the <code>userCookies</code> field. */
public static const USER_COOKIES :String = "userCookies";
/** The field name of the <code>ezGameService</code> field. */
public static const EZ_GAME_SERVICE :String = "ezGameService";
// AUTO-GENERATED: FIELDS END
@@ -38,6 +43,9 @@ public class EZGameObject extends GameObject
/** The current turn holder. */
public var turnHolder :Name;
/** A set of loaded user cookies. */
public var userCookies :DSet;
/** The service interface for requesting special things from the server. */
public var ezGameService :EZGameMarshaller;
@@ -134,6 +142,7 @@ public class EZGameObject extends GameObject
// first read any regular bits
turnHolder = (ins.readObject() as Name);
userCookies = (ins.readObject() as DSet);
ezGameService = (ins.readObject() as EZGameMarshaller);
// then user properties
@@ -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();
}
}
}