I'm dealing with AIR and Sockets, using a Server app and another as Client.
Server sends an object to Client:
clientSocket.writeObject(myObject);
Client has a listener, like this:
socket.addEventListener(ProgressEvent.SOCKET_DATA, socketData);
How can I know the size of the incoming object? I need to monitoring this process, cause when the transfer is complete I need to do another processes.
I tried this, but doesn't work :
var total:int = 0;
private function socketData(e:ProgressEvent) :void {
if (total == 0) {
total = socket.readInt();
}
if (socket.bytesAvailable >= total) {
trace('COMPLETE');
total = 0;
} else {
trace('progress:' + socket.bytesAvailable + ' | total: ' + total);
}
}
This post does not work in my specific case: AS3 / AIR readObject() from socket - How do you check all data has been received?