Zero Module Framework  1.0
A framework for running distributed modules using a ZMQ message bus
 All Classes Namespaces Files Functions Variables Friends Macros
zmf::messaging::ZmqZmfMessagingServiceImplementation Class Reference

#include <ZmqZmfMessagingServiceImplementation.hpp>

Inheritance diagram for zmf::messaging::ZmqZmfMessagingServiceImplementation:
zmf::messaging::IZmfMessagingService

Public Member Functions

 ZmqZmfMessagingServiceImplementation (zmf::data::ModuleUniqueId moduleId)
 
virtual ~ZmqZmfMessagingServiceImplementation ()
 
virtual bool start (IZmfMessagingCoreInterface *const corePtr, std::shared_ptr< zmf::data::ModuleHandle > selfHandle, std::shared_ptr< zmf::config::IConfigurationProvider > config)
 
virtual void stop ()
 
virtual void peerJoin (std::shared_ptr< zmf::data::ModuleHandle > module)
 
virtual void peerLeave (std::shared_ptr< zmf::data::ModuleHandle > module)
 
virtual void subscribe (const zmf::data::MessageType &topic)
 
virtual void unsubscribe (const zmf::data::MessageType &topic)
 
virtual void publish (const zmf::data::ZmfMessage &msg)
 
virtual zmf::data::ZmfInReply sendRequest (const zmf::data::ModuleUniqueId &target, const zmf::data::ZmfMessage &msg)
 
virtual void cancelRequest (uint64_t requestID, bool manual)
 
virtual void sendReply (ExternalRequestIdentity requestID, const zmf::data::ZmfMessage &response)
 
virtual void onDisable ()
 

Detailed Description

"real" implementation of the IZmfMessagingService. Public interface matches IZmfMessagingService

Author
Jan Strauß
Date
created on 7/7/15.

Constructor & Destructor Documentation

zmf::messaging::ZmqZmfMessagingServiceImplementation::ZmqZmfMessagingServiceImplementation ( zmf::data::ModuleUniqueId  moduleId)
zmf::messaging::ZmqZmfMessagingServiceImplementation::~ZmqZmfMessagingServiceImplementation ( )
virtual

Member Function Documentation

void zmf::messaging::ZmqZmfMessagingServiceImplementation::cancelRequest ( uint64_t  requestID,
bool  manual 
)
virtual

Removes the internal resources mapped to the given requestID. To be called internally from a ZmfInReply if it is cancelled.

Parameters
requestIDthe id of the request to cancel

Implements zmf::messaging::IZmfMessagingService.

void zmf::messaging::ZmqZmfMessagingServiceImplementation::onDisable ( )
virtual

to be called when the module is disabled.

Implements zmf::messaging::IZmfMessagingService.

void zmf::messaging::ZmqZmfMessagingServiceImplementation::peerJoin ( std::shared_ptr< zmf::data::ModuleHandle >  module)
virtual

To be called when ZMF learns about a new peer.

Parameters
modulethe ModuleHandle of the joining peer

Implements zmf::messaging::IZmfMessagingService.

void zmf::messaging::ZmqZmfMessagingServiceImplementation::peerLeave ( std::shared_ptr< zmf::data::ModuleHandle >  module)
virtual

To be called when a previously known peer leaves.

Parameters
modulethe ModuleHandle of the leaving peer

Implements zmf::messaging::IZmfMessagingService.

void zmf::messaging::ZmqZmfMessagingServiceImplementation::publish ( const zmf::data::ZmfMessage &  msg)
virtual

Publishes the given ZmfMessage as event under the topic of the message's MessageType

Parameters
msgthe message to publish

Implements zmf::messaging::IZmfMessagingService.

void zmf::messaging::ZmqZmfMessagingServiceImplementation::sendReply ( ExternalRequestIdentity  requestID,
const zmf::data::ZmfMessage &  reply 
)
virtual

Sends the given reply to the sender of the request with the given id. Should be wrapped from the module.

Parameters
requestIDthe id of the request to reply to
responsethe response to send

Implements zmf::messaging::IZmfMessagingService.

zmf::data::ZmfInReply zmf::messaging::ZmqZmfMessagingServiceImplementation::sendRequest ( const zmf::data::ModuleUniqueId &  target,
const zmf::data::ZmfMessage &  msg 
)
virtual

Sends the given message to the given peer. A ZmfInReply is returned providing a handle for the outstanding response.

Parameters
targetthe identity of the receiver
msgthe Message to send
Returns
ZmfInReply a handle for the outstanding response. May be passed to the module.

Implements zmf::messaging::IZmfMessagingService.

bool zmf::messaging::ZmqZmfMessagingServiceImplementation::start ( IZmfMessagingCoreInterface *const  corePtr,
std::shared_ptr< zmf::data::ModuleHandle >  selfHandle,
std::shared_ptr< zmf::config::IConfigurationProvider >  config 
)
virtual

Starts the ZMQ Service. After the service successfully started, the other methods may be called and the implementation will start to deliver incoming events to the provided IZmfMessagingCoreInterface.

Parameters
corepointer to the IZmfMessagingCoreInterface implementation that provides methods implementations of this class will interact with.
selfHandleshared_ptr to the ModuleHandle describing the module instance running on top of this ZMF instance
Returns
Returns true if started successfully, false otherwise

Implements zmf::messaging::IZmfMessagingService.

void zmf::messaging::ZmqZmfMessagingServiceImplementation::stop ( )
virtual

Stops the ZMQ Service. After the service is stopped, calling any method except the start method will not have any effect. Also the implementation will remove any state (peer information, outstanding messages) currently stored.

Implements zmf::messaging::IZmfMessagingService.

void zmf::messaging::ZmqZmfMessagingServiceImplementation::subscribe ( const zmf::data::MessageType &  topic)
virtual

Adds a subscription for the given topic. Semantics are equivalent to the ZMQ subscription ones.

Parameters
topicthe MessageType to subscribe on

Implements zmf::messaging::IZmfMessagingService.

void zmf::messaging::ZmqZmfMessagingServiceImplementation::unsubscribe ( const zmf::data::MessageType &  topic)
virtual

Removes a subscription for the given topic. Semantics are equivalent to the ZMQ subscription ones.

Parameters
topicthe MessageType to unsubscribe from

Implements zmf::messaging::IZmfMessagingService.


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