8. programmer's style guide

TODO

To check the presence and readiness of another agent be sure to use its ready message. The test directory witholds many interesting examples of source code showing how to wait for an agent to join a bus.

If you want your agent A to perform a query, first, you must compute a string, hopefully as unique as possible, that will serve as a token. There is no cross platform/cross language way to implement it ( MAC adress, current time in millisecond, process ID ) on a distributed system with different JVM, so you'll have to rely on a good naming scheme. Once this ID is computed, subscribe to the answer you want to have, and send your message:

String id = myId(serial++);       // returns Example.25432.19 e.g.
MyListener l = new MyListener();  // creates a listener
int tempBinding = bus.bindMsg("^response id="+id+" value=(.*)",l);
l.setValue(tempBinding);	  // for unsubscription
bus.send("request id="+id+" sum a=2 b=2"); // requests
...
public void receive(IvyClient ic,String[] args) {
  ...				  // there is "4" in args[1]
  bus.unBindMsg(bindingInt);
}