If a connection implements the IServiceCapableConnection interface, then it supports calling methods on the client.
![]() |
To call methods from your application on the client, you will first need a reference to the current connection object. |
Example:
IServiceCapableConnection connection = FluorineContext.Current.Connection as IServiceCapableConnection;
if (connection != null)
{
object[] args = new object[] { connection.Client.Id };
connection.invoke("setClientId", args);
}
Client side ActionScript snippet:
nc = new NetConnection();
nc.client = this;
nc.connect("rtmp://localhost/application");
...
function setClientId( id:String ):void
{
trace(id);
}
If you need the result of the method call, you must provide a class that implements the IPendingServiceCallback interface. In the following sample the application adapter implements this interface, and the method call is updated accordingly to pass the IPendingServiceCallback interface.
public class Application : ApplicationAdapter, IPendingServiceCallback
{
public void ResultReceived(IPendingServiceCall call)
{
...
}
private void CallClient()
{
IServiceCapableConnection connection = FluorineContext.Current.Connection as IServiceCapableConnection;
if (connection != null)
{
object[] args = new object[] { connection.Client.Id };
connection.invoke("setClientId", args, this);
}
}
}
![]() |
Additionally the following ApplicationAdapter helper methods can be used to invoke client methods: void InvokeClients(string method, object[] arguments, IPendingServiceCallback callback) void InvokeClients(string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf) void InvokeClients(string method, object[] arguments, IPendingServiceCallback callback, bool ignoreSelf, IScope targetScope) The "targetScope" parameter specifies that clients connected to that scope will be called. |