As you already know, the Massiv simulation is distributed over several nodes. Node objects are special objects that represents these nodes in the simulation. Each node has its node object which resides on that node and is not allowed to migrate.
Each stand-alone managed object has its own unique ObjectId which makes the object addressable in the simulation. The same applies for node objects. The only difference is that their ObjectIds have a special form that allows the Core to easily distinguish between ordinary object ids and ids representing node objects. When a node object needs to be localized the Core contacts the corresponding node directly.
Once the Massiv Core is properly initialized, it asks the application to create the node object which will represent the local node in the simulation. Because service nodes don't participate in the simulation at all, the application should implement two types of node objects. One for server nodes and one for client nodes. Each node object must be derived from Massiv::Core::NodeObjectInterface abstract class.
class NodeObjectInterface : public Object { public: virtual NodeId::Type get_node_type() const = 0; virtual Pointer< AccountObjectInterface > create_account_object() = 0; }; |
The get_node_type() returns type of the node it represents which should be either client or server node type.
The create_account_object() method is used by the Core when it needs to create a new account object. The node object serves here as an account object factory. See Section 14.3, “Account Object” for more information.
The Core does not enforce much requirements on the implementation of server node objects. They are utilized by the Core for automatic creation of account objects only, but the application can and often will extend their functionality beyond the requested requirements. They can serve as an application level interface to connected servers, for example.
The Core asks the application to create an account object (defined on the application level) for a new client when it is just being subscribed into the simulation. See Chapter 28, Handling Accounts for more information.
Client node objects are used by servers to communicate with the corresponding clients on the application level. Because server and client nodes collaborate by using object migration, the server nodes must be able to somehow specify that the destinations of the migrations are client nodes. Objects created on client nodes are not part of the simulation which is distributed over the server nodes and so the server nodes can't know which objects exist on the client nodes and therefore can't address those objects directly. The server nodes always migrate objects to the node objects of the clients. The identifications of the client node objects are always known to all server nodes.