diff --git a/src/as/com/threerings/io/Streamer.as b/src/as/com/threerings/io/Streamer.as index 94fb8b77c..e151236ba 100644 --- a/src/as/com/threerings/io/Streamer.as +++ b/src/as/com/threerings/io/Streamer.as @@ -99,16 +99,7 @@ public class Streamer public function writeObject (obj :Object, out :ObjectOutputStream) :void //throws IOError { - trace("TODO"); - - if (obj is Array) { - trace("Arrays not yet done. Crap!"); - /** - var arr :Array = Array(obj); // not strictly necessary - var length :int = arr.length; - out.writeInt(length); - */ - } + throw new Error("Abstract"); } public function createObject (ins :ObjectInputStream) :Object @@ -121,7 +112,7 @@ public class Streamer public function readObject (obj :Object, ins :ObjectInputStream) :void //throws IOError { - trace("TODO"); + throw new Error("Abstract"); } /** diff --git a/src/as/com/threerings/io/TypedArray.as b/src/as/com/threerings/io/TypedArray.as index 60761b657..0c9ebc53b 100644 --- a/src/as/com/threerings/io/TypedArray.as +++ b/src/as/com/threerings/io/TypedArray.as @@ -1,10 +1,15 @@ package com.threerings.io { +import com.threerings.presents.Log; + public dynamic class TypedArray extends Array { public function TypedArray (jtype :String) { _jtype = jtype; + if (_jtype == "" || _jtype == null) { + Log.info("Created a typed array with bogus type {" + _jtype + "}"); + } } public function getJavaType () :String diff --git a/src/as/com/threerings/io/streamers/ArrayStreamer.as b/src/as/com/threerings/io/streamers/ArrayStreamer.as index 8e5023dfe..318fb7095 100644 --- a/src/as/com/threerings/io/streamers/ArrayStreamer.as +++ b/src/as/com/threerings/io/streamers/ArrayStreamer.as @@ -16,6 +16,7 @@ public class ArrayStreamer extends Streamer { public function ArrayStreamer (jname :String) { + Log.debug("Created an array streamer for type: {" + jname + "}"); super(TypedArray, jname); if (jname.charAt(1) === "[") { diff --git a/src/as/com/threerings/presents/client/Client.as b/src/as/com/threerings/presents/client/Client.as index 91745f2a6..b7c73e704 100644 --- a/src/as/com/threerings/presents/client/Client.as +++ b/src/as/com/threerings/presents/client/Client.as @@ -253,7 +253,7 @@ public class Client extends EventDispatcher */ public function gotPong (pong :PongResponse) :void { - // TODO: compute time delta bowl-shit + // TODO: compute time delta? } /** diff --git a/src/as/com/threerings/presents/client/ClientDObjectMgr.as b/src/as/com/threerings/presents/client/ClientDObjectMgr.as index 8c3427546..b519b9fd7 100644 --- a/src/as/com/threerings/presents/client/ClientDObjectMgr.as +++ b/src/as/com/threerings/presents/client/ClientDObjectMgr.as @@ -78,7 +78,7 @@ public class ClientDObjectMgr _actionInterval = new Timer(500); //TODO! _actionInterval.addEventListener(TimerEvent.TIMER, processNextAction); - _actionInterval.start(); + //_actionInterval.start(); } // documentation inherited from interface DObjectManager @@ -117,6 +117,7 @@ public class ClientDObjectMgr { // queue up an action _actions.push(new ObjectAction(oid, target, subscribe)); + _actionInterval.start(); } // inherit documentation from the interface @@ -180,6 +181,7 @@ public class ClientDObjectMgr { // append it to our queue _actions.push(msg); + _actionInterval.start(); } /** @@ -190,6 +192,7 @@ public class ClientDObjectMgr { // process the next event on our queue if (_actions.length == 0) { + _actionInterval.stop(); return; } @@ -411,7 +414,7 @@ public class ClientDObjectMgr * Called periodically to flush any objects that have been lingering * due to a previously enacted flush delay. */ - protected function flushObjects () :void + protected function flushObjects (event :TimerEvent) :void { var now :Number = new Date().getTime(); for (var oid :String in _flushes.keys()) { diff --git a/src/as/com/threerings/presents/client/Communicator.as b/src/as/com/threerings/presents/client/Communicator.as index c36194716..bd7a74faa 100644 --- a/src/as/com/threerings/presents/client/Communicator.as +++ b/src/as/com/threerings/presents/client/Communicator.as @@ -102,7 +102,7 @@ public class Communicator // write the message (ends up in _outBuffer) _outStream.writeObject(msg); - Log.debug("outBuffer: " + Util.bytesToString(_outBuffer)); +// Log.debug("outBuffer: " + Util.bytesToString(_outBuffer)); // Frame it by writing the length, then the bytes. // We add 4 to the length, because the length is of the entire frame diff --git a/src/as/com/threerings/presents/client/InvocationDirector.as b/src/as/com/threerings/presents/client/InvocationDirector.as index 6b8f95b4a..e9ae485e7 100644 --- a/src/as/com/threerings/presents/client/InvocationDirector.as +++ b/src/as/com/threerings/presents/client/InvocationDirector.as @@ -114,7 +114,9 @@ public class InvocationDirector { _clobj.startTransaction(); try { - for each (var decoder :InvocationDecoder in _reclist) { + for (var itr :IViewCursor = _reclist.getCursor(); itr.moveNext(); ) { + var decoder :InvocationDecoder = + (itr.current as InvocationDecoder); assignReceiverId(decoder); } } finally { diff --git a/src/as/com/threerings/presents/client/TestClient.as b/src/as/com/threerings/presents/client/TestClient.as index f17e094c6..5acc33338 100644 --- a/src/as/com/threerings/presents/client/TestClient.as +++ b/src/as/com/threerings/presents/client/TestClient.as @@ -17,7 +17,7 @@ public class TestClient extends Client var g1 :String = null; var g2 :String = String(g1); - Log.debug("foo: " + (g1 === g2)); + Log.debug("foo: " + (g1 === g2) + ", *" + g2 + "*, " + g2.length); var duckie :Duck = new Goose(); duckie.screw(); @@ -92,10 +92,6 @@ public class TestClient extends Client { var i :int = TimeBaseMarshaller.GET_TIME_OID; } - - public function b () :void - { - } } } @@ -114,7 +110,7 @@ class HelperClass public function HelperClass (cli :TestClient) { _cli = cli; - _cli.b(); + //_cli.b(); } public function hype () :void diff --git a/src/as/com/threerings/presents/dobj/AttributeChangedEvent.as b/src/as/com/threerings/presents/dobj/AttributeChangedEvent.as index acd800b9b..53e3c06fd 100644 --- a/src/as/com/threerings/presents/dobj/AttributeChangedEvent.as +++ b/src/as/com/threerings/presents/dobj/AttributeChangedEvent.as @@ -2,6 +2,9 @@ package com.threerings.presents.dobj { import flash.util.StringBuilder; +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; + /** * An attribute changed event is dispatched when a single attribute of a * distributed object has changed. It can also be constructed to request @@ -60,7 +63,8 @@ public class AttributeChangedEvent extends NamedEvent * used). */ public function AttributeChangedEvent ( - targetOid :int, name :String, value :Object, oldValue :Object) + targetOid :int = 0, name :String = null, value :Object = null, + oldValue :Object = null) { super(targetOid, name); _value = value; @@ -83,6 +87,18 @@ public class AttributeChangedEvent extends NamedEvent buf.append(", value=", _value); } + public override function writeObject (out :ObjectOutputStream) :void + { + super.writeObject(out); + out.writeObject(_value); + } + + public override function readObject (ins :ObjectInputStream) :void + { + super.readObject(ins); + _value = ins.readObject(); + } + protected var _value :Object; protected var _oldValue :Object = UNSET_OLD_ENTRY; } diff --git a/src/as/com/threerings/presents/dobj/DEvent.as b/src/as/com/threerings/presents/dobj/DEvent.as index 9672ad752..3bf7ee934 100644 --- a/src/as/com/threerings/presents/dobj/DEvent.as +++ b/src/as/com/threerings/presents/dobj/DEvent.as @@ -16,6 +16,8 @@ public /* abstract */ class DEvent public function DEvent (targetOid :int) { _toid = targetOid; + + //Log.debug("unset old = " + UNSET_OLD_ENTRY); } /** @@ -126,18 +128,31 @@ public /* abstract */ class DEvent } } -class DummyEntry implements com.threerings.presents.dobj.DSetEntry +/* +import com.threerings.presents.dobj.DSetEntry; + +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; + +class DummyEntry implements DSetEntry { + public function DummyEntry () + { + } + public function getKey () :Object { - return null; + return null; // dummy } - public function writeObject (out :com.threerings.io.ObjectOutputStream) :void + public function writeObject (out :ObjectOutputStream) :void { + // dummy } - public function readObject (ins :com.threerings.io.ObjectInputStream) :void + public function readObject (ins :ObjectInputStream) :void { + // dummy } } +*/ diff --git a/src/as/com/threerings/presents/dobj/DObject.as b/src/as/com/threerings/presents/dobj/DObject.as index eaea8684b..2d4522d8a 100644 --- a/src/as/com/threerings/presents/dobj/DObject.as +++ b/src/as/com/threerings/presents/dobj/DObject.as @@ -92,7 +92,7 @@ public class DObject // extends EventDispatcher event.friendNotifyListener(listener); if (listener is EventListener) { - listener.eventReceived(event); + (listener as EventListener).eventReceived(event); } } catch (e :Error) { Log.warning("Listener choked during notification " + @@ -117,7 +117,6 @@ public class DObject // extends EventDispatcher Log.warning("Unable to post event, object has no omgr " + "[oid=" + getOid() + ", class=" + ClassUtil.getClassName(this) + ", event=" + event + "]."); - } } diff --git a/src/as/com/threerings/presents/dobj/DSet.as b/src/as/com/threerings/presents/dobj/DSet.as index 84075d989..9a6be86fb 100644 --- a/src/as/com/threerings/presents/dobj/DSet.as +++ b/src/as/com/threerings/presents/dobj/DSet.as @@ -11,6 +11,7 @@ import com.threerings.util.Equalable; import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectOutputStream; import com.threerings.io.Streamable; +import com.threerings.io.TypedArray; import com.threerings.presents.Log; @@ -241,7 +242,7 @@ public class DSet return (key as Equalable).equals(otherKey); } else { - throw new Error("Element key is neither simple or Equalabe"); + throw new Error("Element key is neither simple or Equalable"); } } @@ -266,11 +267,12 @@ public class DSet // documentation inherited from interface Streamable public function readObject (ins :ObjectInputStream) :void { - _entries = (ins.readObject() as Array); + _entries = (ins.readObject() as TypedArray); _entries.length = ins.readInt(); // then read the length and limit it } /** The entries of the set (in a sparse array). */ - protected var _entries :Array; + protected var _entries :TypedArray = + new TypedArray("[Lcom.threerings.presents.dobj.DSet$Entry;"); } } diff --git a/src/as/com/threerings/presents/dobj/DummyEntry.as b/src/as/com/threerings/presents/dobj/DummyEntry.as new file mode 100644 index 000000000..f4d94a9c9 --- /dev/null +++ b/src/as/com/threerings/presents/dobj/DummyEntry.as @@ -0,0 +1,31 @@ +package com.threerings.presents.dobj { + +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; + +public class DummyEntry + implements DSetEntry +{ + public function DummyEntry () + { + } + + // documentation inherited from interface DSetEntry + public function getKey () :Object + { + return null; // dummy + } + + // documentation inherited from superinterface Streamable + public function writeObject (out :ObjectOutputStream) :void + { + // dummy + } + + // documentation inherited from superinterface Streamable + public function readObject (ins :ObjectInputStream) :void + { + // dummy + } +} +} diff --git a/src/as/com/threerings/presents/dobj/EntryUpdatedEvent.as b/src/as/com/threerings/presents/dobj/EntryUpdatedEvent.as index 496276f0d..be6974794 100644 --- a/src/as/com/threerings/presents/dobj/EntryUpdatedEvent.as +++ b/src/as/com/threerings/presents/dobj/EntryUpdatedEvent.as @@ -59,7 +59,7 @@ public class EntryUpdatedEvent extends NamedEvent { // only apply the change if we haven't already if (_oldEntry == UNSET_OLD_ENTRY) { - var dset :DSet = target[_name]; + var dset :DSet = (target[_name] as DSet); // fetch the previous value for interested callers _oldEntry = dset.update(_entry); if (_oldEntry == null) { diff --git a/src/as/com/threerings/util/Name.as b/src/as/com/threerings/util/Name.as index dcfa54cb5..e9fa18379 100644 --- a/src/as/com/threerings/util/Name.as +++ b/src/as/com/threerings/util/Name.as @@ -1,11 +1,13 @@ package com.threerings.util { +import com.threerings.util.Equalable; + import com.threerings.io.ObjectInputStream; import com.threerings.io.ObjectOutputStream; import com.threerings.io.Streamable; public class Name extends Object - implements Streamable + implements Equalable, Streamable { public function Name (name :String = "") { @@ -35,16 +37,13 @@ public class Name extends Object return _name; } - // TODO: needed? I'd think so. Maybe we need to create OOObject - // that all our classes can extend that define a reasonable - // equals(). - public function equals (other :Name) :Boolean + // documentation inherited from interface Equalable + public function equals (other :Object) :Boolean { - return getNormal() === other.getNormal(); + return (other is Name) && + (getNormal() === (other as Name).getNormal()); } - // TODO: comparable? - // documentation inherited from interface Streamable public function writeObject (out :ObjectOutputStream) :void //throws IOError