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:
Ray Greenwell
2006-04-06 20:05:28 +00:00
parent f7f9056ed2
commit 64d7f32178
7 changed files with 34 additions and 4 deletions
+7 -1
View File
@@ -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);
}
}
}