BlueZero (BØ)
Middleware for distributed applications
|
The main class used to create a node is b0::Node.
A node implements one part of the protocol, with the other counterpart of the protocol implemented by the resolver node.
Node uses two-phase initialization, so you must call b0::Node::init() after the constructor, and b0::Node::cleanup() before the destructor. Do not call b0::Node::init() from your node class constructor!
Also, b0::Node::spinOnce() must be called periodically to process incoming messages (or just call b0::Node::spin() once).
b0::Node::init() will initialize the node and announce its name to the resolver node, and it will initialize each of its publishers, subscribers, clients and servers.
Any publishers, subscribers, service client and servers must be constructed prior to calling b0::Node::init().
The two ways of interconnecting nodes are:
The functions of the library are not thread-safe, and so are the functions of ZeroMQ. Thus, every node must be accessed always from the same thread.
The most important part of the network is the resolver node.
The resolver node implements a part of the protocol, with the other counterpart of the protocol implemented by the node.
The resolver node is implemented in b0::resolver::Resolver and will provide following services to other nodes:
Important: you must have the resolver node running prior to running any node. See Connecting remote nodes for more information about running distributed nodes.
Example of how to create a simple node with one publisher and sending some messages to some topic:
And the corresponding example of a simple node with one subscriber:
You can have multiple publishers and subscribers as well:
Node with multiple subscribers
And following is an example of using it in a more object-oriented way:
Example of how to create a simple node with a service client:
And the corresponding example of a simple node with a service server:
And the same thing, object-oriented: