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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user