Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
swarmio::transport::zyre::ZyreEndpoint Class Reference

An Endpoint implementation using the Zyre protocol. More...

#include <ZyreEndpoint.h>

Inheritance diagram for swarmio::transport::zyre::ZyreEndpoint:
Inheritance graph
[legend]

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 NodeNodeForUUID (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

ZyreEndpoint::ZyreEndpoint ( const char *  name,
const char *  deviceClass 
)

Construct a new ZyreEndpoint object.

Parameters
nameThe discoverable name of the endpoint
deviceClassDevice class

Definition at line 19 of file ZyreEndpoint.cpp.

ZyreEndpoint::~ZyreEndpoint ( )
overridevirtual

Destroy the ZyreEndpoint object.

Definition at line 357 of file ZyreEndpoint.cpp.

Member Function Documentation

void ZyreEndpoint::Deliver ( moodycamel::BlockingReaderWriterQueue< zyre_event_t * > *  queue)
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.

Returns
std::list<ZyreNode>

Definition at line 674 of file ZyreEndpoint.cpp.

virtual const std::string& swarmio::transport::zyre::ZyreEndpoint::GetUUID ( )
inlineoverridevirtual

Get the UUID of the local node.

Returns
std::string UUID

Implements swarmio::Endpoint.

Definition at line 172 of file ZyreEndpoint.h.

const Node * ZyreEndpoint::NodeForUUID ( const std::string &  uuid)
overridevirtual

Retreive a node by its UUID.

Parameters
uuidUUID
Returns
const Node*

Implements swarmio::Endpoint.

Definition at line 687 of file ZyreEndpoint.cpp.

void ZyreEndpoint::Process ( )
private

Entry point for the worker thread.

Definition at line 372 of file ZyreEndpoint.cpp.

void ZyreEndpoint::Send ( const void *  data,
size_t  size,
const Node node 
)
overrideprotectedvirtual

Called by BasicEndpoint to send serialized messages. Called with node set to nullptr to send a message to all members of the swarm.

Parameters
dataRaw message data
sizeLength of the message data
nodeNode 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.

  • Parameters
    cfgConfig 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.

Parameters
ifnameInterface 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.

Parameters
portPort

Definition at line 64 of file ZyreEndpoint.cpp.

void ZyreEndpoint::Start ( )
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.

void ZyreEndpoint::Stop ( )
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.

Member Data Documentation

ZyreControlSocket swarmio::transport::zyre::ZyreEndpoint::_control
private

Control pipe to shut down event processing.

Definition at line 42 of file ZyreEndpoint.h.

std::shared_timed_mutex swarmio::transport::zyre::ZyreEndpoint::_mutex
private

Mutex protecting the Nodes registry.

Definition at line 54 of file ZyreEndpoint.h.

std::map<std::string, ZyreNode> swarmio::transport::zyre::ZyreEndpoint::_nodes
private

Node registry.

Definition at line 48 of file ZyreEndpoint.h.

std::string swarmio::transport::zyre::ZyreEndpoint::_uuid
private

Local UUID.

Definition at line 66 of file ZyreEndpoint.h.

std::thread* swarmio::transport::zyre::ZyreEndpoint::_worker = nullptr
private

Worker thread.

Definition at line 60 of file ZyreEndpoint.h.

zyre_t* swarmio::transport::zyre::ZyreEndpoint::_zyre
private

Reference to the Zyre structure.

Definition at line 36 of file ZyreEndpoint.h.

unsigned char swarmio::transport::zyre::ZyreEndpoint::bcast_publickey[crypto_box_PUBLICKEYBYTES]
private

Definition at line 81 of file ZyreEndpoint.h.

unsigned char swarmio::transport::zyre::ZyreEndpoint::bcast_secretkey[crypto_box_SECRETKEYBYTES]
private

Definition at line 82 of file ZyreEndpoint.h.

unsigned char swarmio::transport::zyre::ZyreEndpoint::certificate[crypto_box_PUBLICKEYBYTES+crypto_sign_SECRETKEYBYTES]
private

Definition at line 85 of file ZyreEndpoint.h.

std::string swarmio::transport::zyre::ZyreEndpoint::configFilePath = "config.cfg"
private

Definition at line 88 of file ZyreEndpoint.h.

bool swarmio::transport::zyre::ZyreEndpoint::isJoining = false
private

Definition at line 87 of file ZyreEndpoint.h.

unsigned char swarmio::transport::zyre::ZyreEndpoint::my_publickey[crypto_box_PUBLICKEYBYTES]
private

Secret key.

Definition at line 79 of file ZyreEndpoint.h.

unsigned char swarmio::transport::zyre::ZyreEndpoint::my_secretkey[crypto_box_SECRETKEYBYTES]
private

Definition at line 80 of file ZyreEndpoint.h.

bool swarmio::transport::zyre::ZyreEndpoint::security_enabled = false
private

Security enabled bit (if true, communication is secure)

Definition at line 72 of file ZyreEndpoint.h.

unsigned char swarmio::transport::zyre::ZyreEndpoint::server_public[crypto_sign_PUBLICKEYBYTES]
private

Definition at line 84 of file ZyreEndpoint.h.

unsigned char swarmio::transport::zyre::ZyreEndpoint::signature[crypto_sign_SECRETKEYBYTES]
private

Definition at line 83 of file ZyreEndpoint.h.


The documentation for this class was generated from the following files:


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48