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