Posted on Friday 25 March 2005
This one really took me by surprise: if you call several methods through Remoting on the same frame, remoting will group all of the calls in a single Remoting call. That means, in particular, that if you call a remote method 100 times in the same frame, the remote server is called only once and only a single AMF object is received. At the AMF level, there is a int right after the headers for the number of bodys in this single AMF call. That clears up the mystery of BatchFilter in AMFPHP.
On return, Flash ’splits the response’ into several return calls, so this is all entirely transparent. The advantage of this method is obvious: the gateway is created only once instead of several times, only one packet is sent so it’s more efficient and the user needn’t worry about the details of the encoding. Which brings me to my point: if you want to do batch calls with Remoting, simply create a class called BatchCall that can store the calls in an array, add all of the calls you need over the course of several frames and then to send it just loop through the array and call the required methods. Flash will insure that the calls are sent through the network through a single AMF call.


