Modify the listing so that it matches the one below:
import org.swxformat.SWX; var swx:SWX = new SWX(); swx.gateway = "http://localhost:8888/php/swx.php"; swx.encoding = "GET"; swx.debug = true; swx.timeout = 2; // seconds var callParameters:Object = { serviceClass: "Calculator", method: "addNumbers", args: [35, 7], result: [this, resultHandler], timeout: [this, timeoutHandler] } swx.call(callParameters); function resultHandler(event:Object) { status.text = event.result; } function timeoutHandler() { status.text = "Call timed out!"; }
The default timeout duration is 30 seconds but you can override that, as shown here.
In order to make the call actually time out, modify the Calculator class in PHP too to make it sleep for 10 seconds before returning the result. The Calculator class should match the one in the listing below:
<?php class Calculator { function addNumbers($n1, $n2) { sleep(10); // Make the call time out! return $n1 + $n2; } } ?>
Now test your Flash movie and, after two seconds, you should see the SWX call time out. Timed-out calls are cancelled and will not trigger the result handler at any point in the future.

0 Responses to “SWX instance: how to set a timeout handler”
Leave a Reply