Messages are arbitrary binary data so it is the responsibility of the user to make messages self-describing in such as way that messages can be distinguished from one another.
In both cell and background workers, the message reader and writer types are exposed as
Messages in Simulate must have a specified destination. A destination can be a process or multiple processes (in case of a broadcast) or a topic, which represents a particular interest. Unlike messages addressed directly to processes, messages addressed to topics are only delivered to processes that have explicitly registered an interest in that topic.
Messages sent by clients are published to topics that represent an interest in the user ID of that client. In this way, we can ensure that interaction events sent from clients are only received by the Simulate process (or processes) that needs to see them.
The following destinations are possible, and are defined in the
aether::messagenamespace unless otherwise specified. Each is a separate type:
Directed messages allow users to send a message to a specific worker. They are typically used when responding to a request from another worker which was received via a broadcast
- the global state process
- the type used elsewhere in Simulate to represent a worker ID. It is advised not to use worker IDs to address messages since the changing configuration of Simulate cells means that workers may be deallocated or resized in a way that makes delivery to that worker no longer useful.
Broadcast style messages will be delivered to specific workers, however the workers selected will be determines by Simulate based on criteria defined in the destination.
- a broadcast to all workers in the simulation. Use of this should be avoided when possible due to the amount of message traffic it may generate.
- passed a shape that can be either a circle, rectangle or trapezoid or their 3D equivalents, every worker that is managing an area covered by the shape described will receive the message
- this message will be sent to a single worker, Simulate will look to find the Cell Worker that is managing the region of space including the coordinates provided. It no worker is assigned to that region then the worker that is closest to the coordinate will be selected.
closest_worker's constructor takes a single parameter which is the Cartesian coordinate of the destination.
A topic does not define an explicit destination rather, Simulate processes can choose to subscribe to topics they consider relevant, Aether defines a set of standard topics but is it also possible to create your own.
topicsare defined in the
aether::message::topicnamespace. They have the following constructors:
unclaimed_events()(this type cannot be used as a destination and will be discussed later)
When sending messages you are actually creating a list of topics.
topic_listinstance can be constructed via various constructors and static builder functions:
static topic_list topic_list::user_id(uint64_t user_id)
- Builds a
topic_listthat represents interest in messages related to a specified user ID. Interaction messages received from clients are published to topics for the user ID they authenticated as.
static topic_list topic_list::entity_id(uint64_t entity_id)
- Builds a
topic_listthat represents interest in messages related to a specific entity ID. These could be used to send messages to workers containing a specified entity.
static topic_list topic_list::custom_topic(uint64_t id)
- Builds a
topic_listthat represent interest in messages related to a specific integer value. The meaning of this value is not defined by Simulate and can be used to implement custom topics.
topic_list::topic_list(const std::vector<publisher_topic_type> &)
- Builds a
topic_listfrom a vector or brace initialisation list of
publisher_topic_typewhich is a variant of the