Distributed system supports sending distributed messages from any class implementing
IMessageSender to the objects of classes
IMessageReceiver. A custom class can implement both interfaces, address key property will be shared.
Key property of the
IMessageReceiver is an address for the distributed messages. This key must be globally unique and deterministic, on every machine in every Simulation run the key of an object has to return the same value.
Every object that is going to send or receive distributed messages has to register itself in the
MessagesManager. In the Simulator
MessagesManager instance is available in the:
Loader.Instance.Network.MessagesManager, this property has a null reference if the simulation does not use a cluster. Whenever an object is ready to send or receive distributed messages it has to register itself with the
RegisterObject method of the
MessagesManager and when an object will no longer send or receiver messages it has to unregister itself with
UnregisterObject method of the
MessagesManager. Messages received for the unregistered address key will be stored and passed to proper objects after registration.
IMessageSender implementation requires:
UnicastMessage, a basic implementation invokes
UnicastMessagemethod of an
BroadcastMessage, a basic implementation invokes
BroadcastMessagemethod of an
UnicastInitialMessages, requires sending every data required for the object initialization using
IMessageReceiver implementation requires:
ReceiveMessage, parses every incomming data after object is registered.