Server-Side Communication ActionScript > NetConnection.call |
![]() ![]() ![]() |
NetConnection.call
Availability
Flash Communication Server MX.
Usage
myNetConnection
.call(methodName
, [resultObj
,p1, ..., pN
])
Parameters
methodName
A method specified in the form [
objectPath
/]
method
. For example, the command someObj/doSomething
tells the remote server to invoke the clientObj.someObj.doSomething
method, with all the p1, ..., pN
parameters. If the object path is missing, clientObj.doSomething()
is invoked on the remote server.
resultObj
An optional parameter that is used to handle return values from the server. The result object can be any object you defined and can have two defined methods to handle the returned result: onResult
and onStatus
. If an error is returned as the result, onStatus
is invoked; otherwise, onResult
is invoked.
p1, ..., pN
Optional parameters that can be of any ActionScript type, including a reference to another ActionScript object. These parameters are passed to the methodName
specified above when the method is executed on the remote application server.
Returns
For RTMP connections, returns a Boolean value of true
if a call to methodName
is sent to the client; otherwise, false
. For application server connections, it always returns true
.
Description
Method; invokes a command or method on a Flash Communication Server or an application server to which the application instance is connected. The NetConnection.call
method on the server works the same way as the NetConnection.call
method on the client: it invokes a command on a remote server.
Note: If you want to call a method on a client from a server, use the Client.call
method.
Example
This example uses RTMP to execute a call from one Flash Communication Server to another Flash Communication Server. The code makes a connection to the App1 application on server 2 and then invokes the method Sum
on server 2:
nc1.connect("rtmp://server2.mydomain.com/App1", "svr2",); nc1.call("Sum", new Result(), 3, 6);
The following server-side ActionScript code is on server 2. When the client is connecting, this code checks to see whether it has an argument that is equal to svr1
. If the client has that argument, the Sum
method is defined so that when the method is called from svr1, svr2 can respond with the appropriate method:
application.onConnect = function(clientObj){ if(arg1 == "svr1"){ clientObj.Sum = function(p1, p2){ return p1 + p2; } } return true; };
The following example uses an AMF request to make a call to an application server. This allows Flash Communication Server to connect to an application server and then invoke the quote
method. The Java adaptor dispatches the call by using the identifier to the left of the dot as the class name and the identifier to the right of the dot as a method of the class.
nc = new NetConnection; nc.connect("http://www.xyz.com/java"); nc.call("myPackage.quote", new Result());
![]() ![]() ![]() |