Changed some things around with a few helper classes.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3910 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-02 22:20:04 +00:00
parent aabc454801
commit 5558ebd6ca
3 changed files with 46 additions and 38 deletions
@@ -459,6 +459,9 @@ public class ClientDObjectMgr
} }
} }
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.Subscriber;
/** /**
* The object action is used to queue up a subscribe or unsubscribe * The object action is used to queue up a subscribe or unsubscribe
* request. * request.
@@ -466,12 +469,11 @@ public class ClientDObjectMgr
class ObjectAction class ObjectAction
{ {
public var oid :int; public var oid :int;
public var target :com.threerings.presents.dobj.Subscriber; public var target :Subscriber;
public var subscribe :Boolean; public var subscribe :Boolean;
public function ObjectAction ( public function ObjectAction (
oid :int, target :com.threerings.presents.dobj.Subscriber, oid :int, target :Subscriber, subscribe :Boolean)
subscribe :Boolean)
{ {
this.oid = oid; this.oid = oid;
this.target = target; this.target = target;
@@ -494,8 +496,7 @@ class PendingRequest
this.oid = oid; this.oid = oid;
} }
public function addTarget ( public function addTarget (target :Subscriber) :void
target :com.threerings.presents.dobj.Subscriber) :void
{ {
targets.push(target); targets.push(target);
} }
@@ -505,13 +506,12 @@ class PendingRequest
class FlushRecord class FlushRecord
{ {
/** The object to be flushed. */ /** The object to be flushed. */
public var obj :com.threerings.presents.dobj.DObject; public var obj :DObject;
/** The time at which we flush it. */ /** The time at which we flush it. */
public var expire :Number; public var expire :Number;
public function FlushRecord ( public function FlushRecord (obj :DObject, expire :Number)
obj :com.threerings.presents.dobj.DObject, expire :Number)
{ {
this.obj = obj; this.obj = obj;
this.expire = expire; this.expire = expire;
@@ -0,0 +1,35 @@
package com.threerings.presents.client {
import com.threerings.presents.client.InvocationDirector;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.ObjectAccessError;
import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.Log;
/**
* This class is used by the InvocationDirector to subscribe
* to the client object.
*/
internal class ClientSubscriber implements Subscriber
{
public function ClientSubscriber (invdir :InvocationDirector)
{
_invdir = invdir;
}
// documentation inherited from interface Subscriber
public function objectAvailable (obj :DObject) :void
{
_invdir.gotClientObject(obj as ClientObject);
}
// documentation inherited from interface Subscriber
public function requestFailed (oid :int, cause :ObjectAccessError) :void
{
_invdir.gotClientObjectFailed(oid, cause);
}
protected var _invdir :InvocationDirector;
}
}
@@ -308,7 +308,7 @@ public class InvocationDirector
* Called by the ClientSubscriber helper class when the client object * Called by the ClientSubscriber helper class when the client object
* has been returned by the server. * has been returned by the server.
*/ */
public function gotClientObject (clobj :ClientObject) :void internal function gotClientObject (clobj :ClientObject) :void
{ {
clobj.addListener(this); clobj.addListener(this);
clobj.setReceivers(new DSet()); clobj.setReceivers(new DSet());
@@ -321,8 +321,8 @@ public class InvocationDirector
/** /**
* Called by the ClientSubscriber helper class when it fails. * Called by the ClientSubscriber helper class when it fails.
*/ */
public function gotClientObjectFailed (oid :int, cause :ObjectAccessError) internal function gotClientObjectFailed (
:void oid :int, cause :ObjectAccessError) :void
{ {
Log.warning("Invocation director unable to subscribe to " + Log.warning("Invocation director unable to subscribe to " +
"client object [cloid=" + oid + ", cause=" + cause + "]!"); "client object [cloid=" + oid + ", cause=" + cause + "]!");
@@ -366,30 +366,3 @@ public class InvocationDirector
protected const LISTENER_MAX_AGE :int = 90 * 1000; protected const LISTENER_MAX_AGE :int = 90 * 1000;
} }
} }
import com.threerings.presents.client.InvocationDirector;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.ObjectAccessError;
import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.Log;
class ClientSubscriber implements Subscriber
{
public function ClientSubscriber (invdir :InvocationDirector)
{
_invdir = invdir;
}
public function objectAvailable (obj :DObject) :void
{
_invdir.gotClientObject(obj as ClientObject);
}
public function requestFailed (oid :int, cause :ObjectAccessError) :void
{
_invdir.gotClientObjectFailed(oid, cause);
}
protected var _invdir :InvocationDirector;
}