More streaming fixups.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4106 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-05-10 02:35:01 +00:00
parent b82108ecea
commit fe3350dc3c
11 changed files with 46 additions and 65 deletions
@@ -41,28 +41,6 @@ public /* abstract */ class DEvent
return false;
}
/**
* Returns the object id of the client that generated this event. If
* the event was generated by the server, the value returned will be
* -1. This is not valid on the client, it will return -1 for all
* events there (it is primarily provided to allow for event-level
* access control).
*/
public function getSourceOid () :int
{
return _soid;
}
/**
* Do not call this method. Sets the source oid of the client that
* generated this event. It is automatically called by the client
* management code when a client forwards an event to the server.
*/
public function setSourceOid (sourceOid :int) :void
{
_soid = sourceOid;
}
/**
* We want to make the notifyListener method visible to DObject.
*/
@@ -120,9 +98,6 @@ public /* abstract */ class DEvent
/** The oid of the object that is the target of this event. */
protected var _toid :int;
/** The oid of the client that generated this event. */
protected var _soid :int = -1;
protected static const UNSET_OLD_ENTRY :DSetEntry = new DummyEntry();
}
}
@@ -103,6 +103,7 @@ public class DObject // extends EventDispatcher
public function postMessage (name :String, args :Array) :void
{
trace("posting message: " + name + ", " + args);
postEvent(new MessageEvent(_oid, name, args));
}
@@ -242,7 +243,7 @@ public class DObject // extends EventDispatcher
protected function requestEntryAdd (name :String, entry :DSetEntry) :void
{
// dispatch an entry added event
postEvent(new EntryAddedEvent(_oid, name, entry, false));
postEvent(new EntryAddedEvent(_oid, name, entry));
}
/**
@@ -27,7 +27,7 @@ public class EntryAddedEvent extends NamedEvent
* @param entry the entry to add to the set attribute.
*/
public function EntryAddedEvent (
targetOid :int, name :String, entry :DSetEntry)
targetOid :int = 0, name :String = null, entry :DSetEntry = null)
{
super(targetOid, name);
_entry = entry;
@@ -29,11 +29,14 @@ public class EntryRemovedEvent extends NamedEvent
* @param oldEntry the previous value of the entry.
*/
public function EntryRemovedEvent (
targetOid :int, name :String, key :Object, oldEntry :DSetEntry)
targetOid :int = 0, name :String = null, key :Object = null,
oldEntry :DSetEntry = null)
{
super(targetOid, name);
_key = key;
_oldEntry = oldEntry;
if (oldEntry != null) {
_oldEntry = oldEntry;
}
}
/**
@@ -28,11 +28,14 @@ public class EntryUpdatedEvent extends NamedEvent
* @param oldEntry the previous value of the entry.
*/
public function EntryUpdatedEvent (
targetOid :int, name :String, entry :DSetEntry, oldEntry :DSetEntry)
targetOid :int = 0, name :String = null, entry :DSetEntry = null,
oldEntry :DSetEntry = null)
{
super(targetOid, name);
_entry = entry;
_oldEntry = oldEntry;
if (oldEntry != null) {
_oldEntry = oldEntry;
}
}
/**
@@ -2,6 +2,7 @@ package com.threerings.presents.dobj {
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.TypedArray;
import com.threerings.util.StringBuilder;
@@ -26,7 +27,8 @@ public class MessageEvent extends NamedEvent
* @param args the arguments for this message. This array should
* contain only values of valid distributed object types.
*/
public function MessageEvent (targetOid :int, name :String, args :Array)
public function MessageEvent (
targetOid :int = 0, name :String = null, args :Array = null)
{
super(targetOid, name);
_args = args;
@@ -76,6 +78,20 @@ public class MessageEvent extends NamedEvent
buf.append(", args=", _args);
}
// documentation inherited
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeField(_args);
}
// documentation inherited
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
_args = (ins.readField(Array) as Array);
}
protected var _args :Array;
}
}
@@ -109,6 +109,7 @@ public class OidList
public function readObject (ins :ObjectInputStream) :void
{
_oids = (ins.readField("[I") as TypedArray);
_oids.length = ins.readInt();
}
public function toString () :String