User Guide

52 Server-Side ActionScript Language Reference
The following server-side script uses the Client.call() method in the
application.onConnect handler to call the random() method that was defined on the
client side. The server-side script also defines a function called
randHander(), which is used
in the
Client.call() method as the resultObj parameter.
application.onConnect = function(clientObj){
trace("we are connected");
application.acceptConnection(clientObj);
clientObj.call("random", new randHandler());
};
randHandler = function(){
this.onResult = function(res){
trace("random num: " + res);
}
this.onStatus = function(info){
trace("failed and got:" + info.code);
}
};
Client."commandName"
Availability
Flash Communication Server MX 1.0.
Usage
function clientCommand([p1, ..., pN]){}
Parameters
p1, ..., pN Optional parameters passed to the command message handler if the message
contains parameters you defined. These parameters are the ActionScript objects passed to the
NetConnection.call() method.
Returns
Any ActionScript object you define. This object is serialized and sent to the client as a
response to the command only if the command message supplied a response handler.
Description
Event handler; invoked when a Flash client or another server calls the
NetConnection.call() method. A command name parameter is passed to
NetConnection.call() on the client side, which causes Flash Media Server to search the
Client object instance on the server side for a method that matches the command name
parameter. If the parameter is found, the method is invoked and the return value is sent back
to the client.