I'm not understanding something here - in the following excerpted and
simplified example, I'm trying to send a ByteArray of length 170 and there seem
to be 173 bytes received. Where are the "extra" bytes coming from and and is
that the reason readObject returns null? (tracing _socketData.toString shows
that the object properties I want to work with are in the ByteArray):
In the server app:
flash.net.registerClassAlias('foo.bar.SiteVO', SiteVO);
var siteVO:SiteVO = new SiteVO();
siteVO.property = value
...
var bytes:ByteArray = new ByteArray();
bytes.writeObject(siteVO);
_socket.writeUnsignedInt(bytes.length);
_socket.writeObject(bytes);
_socket.flush();
trace(bytes.length) // 170
In the client apps's ProgressEvent handler:
var _socketData:ByteArray = new ByteArray;
trace(_socket.bytesAvailable); // 177
while ( _socket.bytesAvailable > 0 ) {
if (_messageLength == 0) {
_messageLength = _socket.readUnsignedInt();
trace(_messageLength); //177
trace(_socket.bytesAvailable); // 173
}
_socket.readBytes(_socketData);
if (_socketData.length < _messageLength) { // more data coming
break;
}
flash.net.registerClassAlias('foo.bar.SiteVO', SiteVO);
var result:SiteVO = _socketData.readObject() as SiteVO;
trace(result); // null
On 2/15/12 1:39 PM, "Henrik Andersson" <[email protected]> wrote:
Mattheis, Erik (MIN-WSW) skriver:
> If I have to do this without looking at functional examples, how would one
> transmit a terminator byte or byte size while using Socket.writeObject()?
Write the object to a ByteArray, measure the size of that and send the
size of that before the contents of the ByteArray.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_ _ _
Erik Mattheis | Weber Shandwick
P: (952) 346.6610
M: (612) 377.2272
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders