Notes
Sunday April 20, 2003
Invoking remote methods sequentially
If you have more than one task to perform on the server, without flash having to handle the data until the last task is completed, you should use the delayExecute() and execute() methods of PHPObject to invoke remote methods in batches.
Before we proceed, we look at what goes behind the scenes. When a remote method is called, PHPObject serializes the properties of the object making the call, and transmits this data to the php class. After the remote method completes, php returns data back to flash. If you call remote methods one after another the usual way, you will be wasting bandwidth since you are transmitting the same object properties to and fro the server. You will also be wasting CPU resources serializing and unserializing the same data. Since the php class already knows the latest object properties, it should proceed to perform the next tasks before returning results back to flash.
Here is how we invoke remote methods sequentially in PHPObject:
myObj.doRemoteMethod1(param1,param2,...);
myObj.doRemoteMethod2(param1,param2,...);
myObj.doRemoteMethod1(param1,param2,...);
myObj.doRemoteMethod3(param1,param2,...);
myObj.execute();
In the above example, data is transmitted to and fro the server only once. The php class will first execute doRemoteMethod1(), then doRemoteMethod2(), then doRemoteMethod1() again, and then doRemoteMethod3(), before sending the final data back to flash. Since the last method called is doRemoteMethod3, you should catch the server results in flash using
trace(result);
}
Posted by sunny at April 20, 2003 09:15 AM
|
Comments
|
