Af2SharedObject.send - affluxis/csjava GitHub Wiki

Usage
mySo.send(methodName, pN)

Parameters
methodName - The name of a method on a client shared object instance. For example, if you specify doSomething, the client must invoke the Af2SharedObject.onSend method, with all the pN parameters.
pN - Parameters of any JavaScript object, including references to other Java objects. These parameters are passed to the specified onSend event handler when it executes on the client runtime.

Description
Method; executes a method in a client and server-side scripts. You can use Af2SharedObject.send to asynchronously execute a method on all the clients subscribing to a shared object.

Example
This example calls the Af2SharedObject.send method to execute the doSomething method in the client-side and passes doSomething the string 'this is a test'.

var myShared = Af2SharedObject.get("foo", true);
myShared.send("doSomething"', "this is a test");

The following example is the client-side code that defines the doSomething method:

connection = new Af2NetConnection(this);
connection.connect("subdomain.domain.com/someApp");
var x = Af2SharedObject.get("foo", true);
x.connect(connection);
x.onSend(info -> {
  // process the str
  Log.d("affluxis', "method: " + info.method);
  Log.d("affluxis", "parameters: " + info.parameters);
});