ZeroEQ
0.7.0
ZeroEQ - Zero Event Queue
|
Subscribes to Publisher to receive events. More...
#include <subscriber.h>
Public Member Functions | |
Subscriber () | |
Create a default subscriber. More... | |
Subscriber (const std::string &session) | |
Create a subscriber which subscribes to publisher(s) from the given session. More... | |
Subscriber (const URI &uri) | |
Create a subscriber which subscribes to a specific publisher. More... | |
Subscriber (const URI &uri, const std::string &session) | |
Create a subscriber which subscribes to publisher(s) on the given URI. More... | |
Subscriber (Receiver &shared) | |
Create a default shared subscriber. More... | |
Subscriber (const std::string &session, Receiver &shared) | |
Create a shared subscriber which subscribes to publisher(s) from the given session. More... | |
Subscriber (const URI &uri, Receiver &shared) | |
Create a shared subscriber which subscribes to publisher(s) on the given URI. More... | |
Subscriber (const URI &uri, const std::string &session, Receiver &shared) | |
Create a subscriber which subscribes to publisher(s) on the given URI. More... | |
~Subscriber () | |
Destroy this subscriber and withdraw any subscriptions. More... | |
bool | subscribe (servus::Serializable &serializable) |
Subscribe a serializable object to receive updates from any connected publisher. More... | |
bool | subscribe (const uint128_t &event, const EventFunc &func) |
Subscribe to an event from any connected publisher. More... | |
bool | subscribe (const uint128_t &event, const EventPayloadFunc &func) |
Subscribe to an event with payload from any connected publisher. More... | |
bool | unsubscribe (const servus::Serializable &serializable) |
Unsubscribe a serializable object to stop applying updates from any connected publisher. More... | |
bool | unsubscribe (const uint128_t &event) |
const std::string & | getSession () const |
Public Member Functions inherited from zeroeq::Receiver | |
Receiver () | |
Create a new standalone receiver. More... | |
Receiver (Receiver &shared) | |
Create a shared receiver. More... | |
virtual | ~Receiver () |
Destroy this receiver. More... | |
bool | receive (const uint32_t timeout=TIMEOUT_INDEFINITE) |
Receive at least one event from all shared receivers. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from zeroeq::Receiver | |
void * | getZMQContext () |
Subscribes to Publisher to receive events.
If the subscriber is in the same session as discovered publishers, it automatically subscribes to those publishers. Publishers from the same application instance are not considered though.
A subscription to a non-existing publisher is valid. It will start receiving events once the other publisher(s) is(are) publishing.
A receive on any Subscriber of a shared group will work on all subscribers and call the registered handlers.
Not thread safe.
Example:
Definition at line 33 of file subscriber.h.
zeroeq::Subscriber::Subscriber | ( | ) |
Create a default subscriber.
Postconditions:
std::runtime_error | if ZeroConf is not available |
|
explicit |
Create a subscriber which subscribes to publisher(s) from the given session.
Postconditions:
session | session name used for filtering of discovered publishers |
std::runtime_error | if ZeroConf is not available |
|
explicit |
zeroeq::Subscriber::Subscriber | ( | const URI & | uri, |
const std::string & | session | ||
) |
Create a subscriber which subscribes to publisher(s) on the given URI.
The discovery and filtering by session is only used if the URI is not fully qualified.
Postconditions:
uri | publisher URI in the format [scheme://][*|host|IP|IF][:port] |
session | session name used for filtering of discovered publishers |
std::runtime_error | if ZeroConf is not available or if session name is invalid |
zeroeq::Subscriber::Subscriber | ( | Receiver & | shared | ) |
Create a default shared subscriber.
shared | another receiver to share data reception with |
zeroeq::Subscriber::Subscriber | ( | const std::string & | session, |
Receiver & | shared | ||
) |
Create a shared subscriber which subscribes to publisher(s) from the given session.
session | only subscribe to publishers of the same session |
shared | another receiver to share data reception with |
Create a shared subscriber which subscribes to publisher(s) on the given URI.
uri | publisher URI in the format [scheme://]*|host|IP|IF:port |
shared | another receiver to share data reception with |
zeroeq::Subscriber::~Subscriber | ( | ) |
Destroy this subscriber and withdraw any subscriptions.
const std::string& zeroeq::Subscriber::getSession | ( | ) | const |
bool zeroeq::Subscriber::subscribe | ( | servus::Serializable & | serializable | ) |
Subscribe a serializable object to receive updates from any connected publisher.
Every update will be directly applied on the object during receive(). To track updates on the object, the serializable's updated function is called accordingly.
The subscribed object instance has to be valid until unsubscribe().
serializable | the object to update on receive() |
bool zeroeq::Subscriber::subscribe | ( | const uint128_t & | event, |
const EventFunc & | func | ||
) |
Subscribe to an event from any connected publisher.
Every receival of the event will call the registered callback function.
event | the event identifier to subscribe to |
func | the callback function called upon receival |
bool zeroeq::Subscriber::subscribe | ( | const uint128_t & | event, |
const EventPayloadFunc & | func | ||
) |
Subscribe to an event with payload from any connected publisher.
Every receival of the event will call the registered callback function.
event | the event identifier to subscribe to |
func | the callback function called upon receival |
bool zeroeq::Subscriber::unsubscribe | ( | const servus::Serializable & | serializable | ) |
Unsubscribe a serializable object to stop applying updates from any connected publisher.
serializable | the object to stop updating on receive() |