An Endpoint implementation using the Zyre protocol. More...
#include <ZyreEndpoint.h>
Public Member Functions | |
std::list< const ZyreNode * > | GetNodes () |
Get a list of known Nodes. More... | |
virtual const std::string & | GetUUID () override |
Get the UUID of the local node. More... | |
virtual const Node * | NodeForUUID (const std::string &uuid) override |
Retreive a node by its UUID. More... | |
void | SetConfig (std::string cfg) |
Set the config file path. More... | |
void | SetInterface (const char *ifname) |
Set the network interface to bind to. More... | |
void | SetPort (uint16_t port) |
Set the port used by the endpoint. More... | |
virtual void | Start () override |
Start the background thread, announce the Zyre node and start processing messages. More... | |
virtual void | Stop () override |
Send a termination signal and wait until the endpoint finished processing messages. More... | |
ZyreEndpoint (const char *name, const char *deviceClass) | |
Construct a new ZyreEndpoint object. More... | |
virtual | ~ZyreEndpoint () override |
Destroy the ZyreEndpoint object. More... | |
Public Member Functions inherited from swarmio::transport::BasicEndpoint | |
bool | IsRunning () |
Checks whether the endpoint has been started. More... | |
virtual void | Send (data::Message *message, const Node *node) override |
Send a message to a specific member of the swarm. Call with node set to nullptr to send a message to all members of the swarm. More... | |
virtual void | Tag (data::Message *message) override |
Set the message identifier for a message. More... | |
Public Member Functions inherited from swarmio::Endpoint | |
virtual | ~Endpoint () |
Destroy the Endpoint object. More... | |
Protected Member Functions | |
virtual void | Send (const void *data, size_t size, const Node *node) override |
Called by BasicEndpoint to send serialized messages. Called with node set to nullptr to send a message to all members of the swarm. More... | |
Protected Member Functions inherited from swarmio::transport::BasicEndpoint | |
BasicEndpoint () | |
Protected constructor. More... | |
virtual void | NodeDidJoin (const Node *node) noexcept |
Called when a new Node has joined the group. More... | |
virtual void | NodeWasDiscovered (const Node *node) noexcept |
Called when a new Node has been discovered. More... | |
virtual void | NodeWillLeave (const Node *node) noexcept |
Called when a Node signals that it will leave. More... | |
virtual bool | ReceiveMessage (const Node *sender, const data::Message *message) noexcept |
Called by implementations to deliver decoded messages. More... | |
virtual bool | ReceiveMessage (const Node *sender, const void *data, size_t size) noexcept |
Called by implementations to deliver raw messages. More... | |
virtual void | RegisterMailbox (Mailbox *mailbox) override |
Register a Mailbox to receive messages. More... | |
virtual void | ReplaceMailbox (Mailbox *oldMailbox, Mailbox *newMailbox) override |
Relocate a mailbox to another in-memory location. More... | |
virtual void | UnregisterMailbox (Mailbox *mailbox) override |
Unregister a Mailbox from receiving messages. More... | |
Private Member Functions | |
void | Deliver (moodycamel::BlockingReaderWriterQueue< zyre_event_t * > *queue) |
Entry point for the delivery thread. More... | |
void | Process () |
Entry point for the worker thread. More... | |
Private Attributes | |
ZyreControlSocket | _control |
Control pipe to shut down event processing. More... | |
std::shared_timed_mutex | _mutex |
Mutex protecting the Nodes registry. More... | |
std::map< std::string, ZyreNode > | _nodes |
Node registry. More... | |
std::string | _uuid |
Local UUID. More... | |
std::thread * | _worker = nullptr |
Worker thread. More... | |
zyre_t * | _zyre |
Reference to the Zyre structure. More... | |
unsigned char | bcast_publickey [crypto_box_PUBLICKEYBYTES] |
unsigned char | bcast_secretkey [crypto_box_SECRETKEYBYTES] |
unsigned char | certificate [crypto_box_PUBLICKEYBYTES+crypto_sign_SECRETKEYBYTES] |
std::string | configFilePath = "config.cfg" |
bool | isJoining = false |
unsigned char | my_publickey [crypto_box_PUBLICKEYBYTES] |
Secret key. More... | |
unsigned char | my_secretkey [crypto_box_SECRETKEYBYTES] |
bool | security_enabled = false |
Security enabled bit (if true, communication is secure) More... | |
unsigned char | server_public [crypto_sign_PUBLICKEYBYTES] |
unsigned char | signature [crypto_sign_SECRETKEYBYTES] |
Additional Inherited Members | |
Protected Attributes inherited from swarmio::Endpoint | |
friend | Mailbox |
Allow Mailboxes to register themselves. More... | |
An Endpoint implementation using the Zyre protocol.
Zyre provides reliable group messaging over local area networks. It uses UDP beacons for discovery and full-fledged TCP based ZeroMQ messages for reliable communication within the group. Zyre endpoints leverage the protocol for both transmission and node discovery.
Definition at line 29 of file ZyreEndpoint.h.
ZyreEndpoint::ZyreEndpoint | ( | const char * | name, |
const char * | deviceClass | ||
) |
Construct a new ZyreEndpoint object.
name | The discoverable name of the endpoint |
deviceClass | Device class |
Definition at line 19 of file ZyreEndpoint.cpp.
|
overridevirtual |
Destroy the ZyreEndpoint object.
Definition at line 357 of file ZyreEndpoint.cpp.
|
private |
Entry point for the delivery thread.
Definition at line 454 of file ZyreEndpoint.cpp.
std::list< const ZyreNode * > ZyreEndpoint::GetNodes | ( | ) |
Get a list of known Nodes.
Definition at line 674 of file ZyreEndpoint.cpp.
|
inlineoverridevirtual |
Get the UUID of the local node.
Implements swarmio::Endpoint.
Definition at line 172 of file ZyreEndpoint.h.
|
overridevirtual |
Retreive a node by its UUID.
uuid | UUID |
Implements swarmio::Endpoint.
Definition at line 687 of file ZyreEndpoint.cpp.
|
private |
Entry point for the worker thread.
Definition at line 372 of file ZyreEndpoint.cpp.
|
overrideprotectedvirtual |
Called by BasicEndpoint to send serialized messages. Called with node set to nullptr to send a message to all members of the swarm.
data | Raw message data |
size | Length of the message data |
node | Node the message will be sent to |
Implements swarmio::transport::BasicEndpoint.
Definition at line 306 of file ZyreEndpoint.cpp.
void ZyreEndpoint::SetConfig | ( | std::string | cfg | ) |
Set the config file path.
cfg | Config file path |
Definition at line 88 of file ZyreEndpoint.cpp.
void ZyreEndpoint::SetInterface | ( | const char * | ifname | ) |
Set the network interface to bind to.
Will throw an exception if the node is running.
ifname | Interface name |
Definition at line 76 of file ZyreEndpoint.cpp.
void ZyreEndpoint::SetPort | ( | uint16_t | port | ) |
Set the port used by the endpoint.
Will throw an exception if the node is running.
port | Port |
Definition at line 64 of file ZyreEndpoint.cpp.
|
overridevirtual |
Start the background thread, announce the Zyre node and start processing messages.
Reimplemented from swarmio::transport::BasicEndpoint.
Definition at line 93 of file ZyreEndpoint.cpp.
|
overridevirtual |
Send a termination signal and wait until the endpoint finished processing messages.
Reimplemented from swarmio::transport::BasicEndpoint.
Definition at line 277 of file ZyreEndpoint.cpp.
|
private |
Control pipe to shut down event processing.
Definition at line 42 of file ZyreEndpoint.h.
|
private |
Mutex protecting the Nodes registry.
Definition at line 54 of file ZyreEndpoint.h.
|
private |
Node registry.
Definition at line 48 of file ZyreEndpoint.h.
|
private |
Local UUID.
Definition at line 66 of file ZyreEndpoint.h.
|
private |
Worker thread.
Definition at line 60 of file ZyreEndpoint.h.
|
private |
Reference to the Zyre structure.
Definition at line 36 of file ZyreEndpoint.h.
|
private |
Definition at line 81 of file ZyreEndpoint.h.
|
private |
Definition at line 82 of file ZyreEndpoint.h.
|
private |
Definition at line 85 of file ZyreEndpoint.h.
|
private |
Definition at line 88 of file ZyreEndpoint.h.
|
private |
Definition at line 87 of file ZyreEndpoint.h.
|
private |
Secret key.
Definition at line 79 of file ZyreEndpoint.h.
|
private |
Definition at line 80 of file ZyreEndpoint.h.
|
private |
Security enabled bit (if true, communication is secure)
Definition at line 72 of file ZyreEndpoint.h.
|
private |
Definition at line 84 of file ZyreEndpoint.h.
|
private |
Definition at line 83 of file ZyreEndpoint.h.