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:
@@ -94,7 +94,7 @@ public class OccupantInfo
|
||||
// documentation inherited from superinterface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
bodyOid = (ins.readObject() as Integer);
|
||||
bodyOid = (ins.readField(Integer) as Integer);
|
||||
username = (ins.readObject() as Name);
|
||||
status = ins.readByte();
|
||||
}
|
||||
|
||||
@@ -31,12 +31,14 @@ public class ObjectInputStream
|
||||
public function readObject () :Object
|
||||
//throws IOError
|
||||
{
|
||||
var DEBUG_ID :String = "[" + (++_tempy) + "] ";
|
||||
try {
|
||||
// read in the class code for this instance
|
||||
var code :int = readShort();
|
||||
|
||||
// a zero code indicates a null value
|
||||
if (code == 0) {
|
||||
Log.debug(DEBUG_ID + "Read null");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -50,7 +52,7 @@ public class ObjectInputStream
|
||||
|
||||
// read in the class metadata
|
||||
var cname :String = Translations.getFromServer(readUTF());
|
||||
Log.debug("read cname: " + cname);
|
||||
// Log.debug("read cname: " + cname);
|
||||
var streamer :Streamer = Streamer.getStreamerByJavaName(cname);
|
||||
if (streamer == Streamer.BAD_STREAMER) {
|
||||
Log.warning("OMG, cannot stream " + cname);
|
||||
@@ -60,10 +62,11 @@ public class ObjectInputStream
|
||||
|
||||
cmap = new ClassMapping(code, cname, streamer);
|
||||
_classMap[code] = cmap;
|
||||
// Log.debug("Created mapping for (" + code + "): " + cname);
|
||||
Log.debug(DEBUG_ID +
|
||||
"Created mapping: (" + code + "): " + cname);
|
||||
|
||||
} else {
|
||||
Log.debug("Read known code: " + code);
|
||||
Log.debug(DEBUG_ID + "Read known code: (" + code + ")");
|
||||
cmap = (_classMap[code] as ClassMapping);
|
||||
if (null == cmap) {
|
||||
throw new IOError("Read object for which we have no " +
|
||||
@@ -71,7 +74,7 @@ public class ObjectInputStream
|
||||
}
|
||||
}
|
||||
|
||||
Log.debug("Creating object sleeve...");
|
||||
// Log.debug("Creating object sleeve...");
|
||||
var target :Object;
|
||||
if (cmap.streamer === null) {
|
||||
var clazz :Class = ClassUtil.getClassByName(cmap.classname);
|
||||
@@ -80,9 +83,9 @@ public class ObjectInputStream
|
||||
} else {
|
||||
target = cmap.streamer.createObject(this);
|
||||
}
|
||||
Log.debug("Reading object...");
|
||||
//Log.debug("Reading object...");
|
||||
readBareObjectImpl(target, cmap.streamer);
|
||||
Log.debug("Read object: " + target);
|
||||
Log.debug(DEBUG_ID + "Read object: " + target);
|
||||
return target;
|
||||
|
||||
} catch (me :MemoryError) {
|
||||
@@ -229,5 +232,10 @@ public class ObjectInputStream
|
||||
|
||||
/** A map of short class code to ClassMapping info. */
|
||||
protected var _classMap :Array = new Array();
|
||||
|
||||
|
||||
|
||||
|
||||
static var _tempy :int = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.threerings.io {
|
||||
|
||||
public dynamic class StreamableArray extends Array
|
||||
implements Streamable
|
||||
{
|
||||
public function StreamableArray (ctype :Class = undefined, length :int = 0)
|
||||
{
|
||||
super(length);
|
||||
_ctype = ctype;
|
||||
}
|
||||
|
||||
public function StreamableArray (ctype :Class, ... values)
|
||||
{
|
||||
super(values);
|
||||
_ctype = ctype;
|
||||
}
|
||||
|
||||
/** The type of all the elements in the array. */
|
||||
protected var _ctype :Class;
|
||||
}
|
||||
@@ -152,12 +152,6 @@ public class InvocationDirector
|
||||
var event :InvocationRequestEvent =
|
||||
new InvocationRequestEvent(invOid, invCode, methodId, args);
|
||||
|
||||
// because invocation directors are used on the server, we set the
|
||||
// source oid here so that invocation requests are properly
|
||||
// attributed to the right client object when created by
|
||||
// server-side entities only sort of pretending to be a client
|
||||
event.setSourceOid(_clobj.getOid());
|
||||
|
||||
// now, dispatch the event
|
||||
_omgr.postEvent(event);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user