Quantcast
Channel: Adobe Community : All Content - AIR Development
Viewing all articles
Browse latest Browse all 2954

ServerSocket. Is there a way to know the total size of arriving data?

$
0
0

Hi. I have two apps: a server and a client.

 

Server sends to client different types of data inside an Object:

 

var data:Object  = {

     bdata1 : bitmapdata_A,    

     bdata2 : bitmapdata_B,   

     bdata3 : bitmapdata_C,

}

 

clientsocket.writeUTF( 'Hello I'm sending some bitmaps!');

clientsocket.writeObject(data);

clientsocket.flush();

 

... client receives it:

 

socket.addEventListener(ProgressEvent.SOCKET_DATA, socketData);

private function socketData(e:ProgressEvent):void {


     trace(server.readUTF());

 

     var data:Object = server.readObject();

 

}

 

Problem: When the object "data" is a simple object (strings, number, boolean), the process is successfully,

 

but when I try to send bitmapdata, the program broke, because client try to read an object that is not completed transferred.

 

There is a way to know the size of the incoming data, and handle it when the transfer is finished? Thanks.

 

Message was edited by: que_onda


Viewing all articles
Browse latest Browse all 2954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>