A simple, fast and safe way to implement communication between agents
Agents in Artificial Life can communicate with each other through two different ways: By calling methods of other agents or by using the built-in messaging system: Messenger. The first method's main disadvantage is that it may generate dead locks without having the possibility to detect them. Whereas, Messenger has been designed from scratch to enable in an easy, fast and safe way the communication between agents. All agents in Artificial Life may communicate with each other by implementing the Messenger's interface, which defines the call back methods used to receive messages. The messages are forwarded to the agents by a MessageHandler object. An application may declare many MessageHandler objects creating then many communication channels. MessageHandler forwards messages to the agents by using their memory address avoiding any translation and resulting in a very fast message forwarding.
Messenger may be used for any other needs in terms of communication; it is not tight to agents.
Artificial Life provides two API based on Messenger: Method Invocator and Event. Method Invocator is a method invocation API that gives you the possibility to invoke any method on any object. Event is a trade safe event mechanism where events can be queued.
You can find an example of code using Method Invocator here and an example of code using Event here.
