Lots of debug logging, some casting.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4001 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -24,6 +24,7 @@ package com.threerings.crowd.data {
|
||||
import com.threerings.util.Byte;
|
||||
import com.threerings.util.Name;
|
||||
|
||||
//import com.threerings.presents.Log;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
|
||||
@@ -119,6 +120,7 @@ public class BodyObject extends ClientObject
|
||||
public override function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
super.writeObject(out);
|
||||
|
||||
out.writeObject(username);
|
||||
out.writeInt(location);
|
||||
out.writeByte(status);
|
||||
@@ -128,9 +130,14 @@ public class BodyObject extends ClientObject
|
||||
public override function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
super.readObject(ins);
|
||||
|
||||
Log.debug("Reading username");
|
||||
username = (ins.readObject() as Name);
|
||||
Log.debug("Reading location");
|
||||
location = ins.readInt();
|
||||
Log.debug("Reading status");
|
||||
status = ins.readByte();
|
||||
Log.debug("Reading awayMessage");
|
||||
awayMessage = (ins.readField(String) as String);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import flash.net.Socket;
|
||||
import flash.util.ByteArray;
|
||||
import flash.util.Endian;
|
||||
|
||||
import com.threerings.presents.Log;
|
||||
|
||||
/**
|
||||
* Reads socket data until a complete frame is available.
|
||||
* This dispatches a FrameAvailableEvent.FRAME_AVAILABLE once a frame
|
||||
@@ -26,6 +28,7 @@ public class FrameReader extends EventDispatcher
|
||||
*/
|
||||
protected function socketHasData (event :ProgressEvent) :void
|
||||
{
|
||||
Log.debug("socketHasData(" + _socket.bytesAvailable + ")");
|
||||
if (_curData == null) {
|
||||
if (_socket.bytesAvailable < HEADER_SIZE) {
|
||||
// if there are less bytes available than a header, let's
|
||||
@@ -51,12 +54,15 @@ public class FrameReader extends EventDispatcher
|
||||
if (_length === _curData.length) {
|
||||
// we have now read a complete frame, let us dispatch the data
|
||||
_curData.position = 0; // move the read pointer to the beginning
|
||||
Log.debug("+ FrameAvailable");
|
||||
dispatchEvent(new FrameAvailableEvent(_curData));
|
||||
_curData = null; // clear, so we know we need to first read length
|
||||
|
||||
// there's a good chance there's more on the socket, recurse
|
||||
// now to read it
|
||||
socketHasData(event);
|
||||
if (_socket.bytesAvailable >= HEADER_SIZE) {
|
||||
socketHasData(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,11 +56,14 @@ public class ObjectInputStream
|
||||
Log.warning("OMG, cannot stream " + cname);
|
||||
return null;
|
||||
}
|
||||
Log.debug("Got streamer (" + streamer + ")");
|
||||
|
||||
cmap = new ClassMapping(code, cname, streamer);
|
||||
_classMap[code] = cmap;
|
||||
Log.debug("Created mapping for (" + code + "): " + cname);
|
||||
|
||||
} else {
|
||||
Log.debug("Read known code: " + code);
|
||||
cmap = (_classMap[code] as ClassMapping);
|
||||
if (null == cmap) {
|
||||
throw new IOError("Read object for which we have no " +
|
||||
@@ -68,6 +71,7 @@ public class ObjectInputStream
|
||||
}
|
||||
}
|
||||
|
||||
Log.debug("Creating object sleeve...");
|
||||
var target :Object;
|
||||
if (cmap.streamer === null) {
|
||||
var clazz :Class = flash.util.getClassByName(cmap.classname);
|
||||
@@ -76,7 +80,9 @@ public class ObjectInputStream
|
||||
} else {
|
||||
target = cmap.streamer.createObject(this);
|
||||
}
|
||||
Log.debug("Reading object...");
|
||||
readBareObjectImpl(target, cmap.streamer);
|
||||
Log.debug("Read object: " + target);
|
||||
return target;
|
||||
|
||||
} catch (me :MemoryError) {
|
||||
@@ -95,7 +101,7 @@ public class ObjectInputStream
|
||||
{
|
||||
// streamable objects
|
||||
if (streamer == null) {
|
||||
obj.readObject(this); // obj is a Streamable.
|
||||
(obj as Streamable).readObject(this);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ public class Streamer
|
||||
initStreamers();
|
||||
|
||||
// see if we have a streamer for it
|
||||
Log.debug("getStreamer/existing");
|
||||
for each (var streamer :Streamer in _streamers) {
|
||||
if (streamer.getJavaClassName() === jname) {
|
||||
return streamer;
|
||||
@@ -79,6 +80,7 @@ public class Streamer
|
||||
}
|
||||
|
||||
// see if it's an array that we unstream using an ArrayStreamer
|
||||
Log.debug("getStreamer/array");
|
||||
if (jname.charAt(0) === "[") {
|
||||
var streamer :Streamer = new ArrayStreamer(jname);
|
||||
_streamers.push(streamer);
|
||||
@@ -86,8 +88,10 @@ public class Streamer
|
||||
}
|
||||
|
||||
// otherwise see if it represents a Streamable
|
||||
Log.debug("getStreamer/Class:Streamable");
|
||||
var clazz :Class = ClassUtil.getClassByName(
|
||||
Translations.getFromServer(jname));
|
||||
Log.debug("getStreamer/Class:Streamable2");
|
||||
if (ClassUtil.isAssignableAs(Streamable, clazz)) {
|
||||
return null; // it's streamable
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ public class ClientDObjectMgr
|
||||
dispatchEvent(evt);
|
||||
|
||||
} else if (obj is ObjectResponse) {
|
||||
registerObjectAndNotify(obj.getObject());
|
||||
registerObjectAndNotify((obj as ObjectResponse).getObject());
|
||||
|
||||
} else if (obj is UnsubscribeResponse) {
|
||||
var oid :int = obj.getOid();
|
||||
@@ -306,9 +306,11 @@ public class ClientDObjectMgr
|
||||
"[oid=" + oid + ", obj=" + obj + "].");
|
||||
return;
|
||||
}
|
||||
Log.debug("Got object: pendReq=" + req);
|
||||
|
||||
for (var ii :int = 0; ii < req.targets.length; ii++) {
|
||||
var target :Subscriber = req.targets[ii];
|
||||
var target :Subscriber = (req.targets[ii] as Subscriber);
|
||||
Log.debug("Notifying subscriber: " + target);
|
||||
// add them as a subscriber
|
||||
obj.addSubscriber(target);
|
||||
// and let them know that the object is in
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.threerings.presents.dobj {
|
||||
|
||||
import com.threerings.presents.Log;
|
||||
|
||||
public class SubscriberAdapter
|
||||
implements Subscriber
|
||||
{
|
||||
@@ -12,6 +14,7 @@ public class SubscriberAdapter
|
||||
// documentation inherited from interface Subscriber
|
||||
public function objectAvailable (obj :DObject) :void
|
||||
{
|
||||
Log.debug("calling success function: " + _success);
|
||||
_success(obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ public class ArrayUtil
|
||||
*/
|
||||
public static function indexOf (arr :Array, element :Object) :int
|
||||
{
|
||||
// return mx.utils.ArrayUtil.getItemIndex(element, arr);
|
||||
//
|
||||
for (var ii :int = 0; ii < arr.length; ii++) {
|
||||
if (arr[ii] === element) {
|
||||
return ii;
|
||||
|
||||
Reference in New Issue
Block a user