ZeroEQ
0.9.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 URIs &uris) | |
Create a subscriber which subscribes to specific publishers. 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 URIs &uris, Receiver &shared) | |
Create a shared subscriber which subscribes to publishers on the given URIs. More... | |
~Subscriber () | |
Destroy this subscriber and withdraw any subscriptions. More... | |
Subscriber (const URI &uri) | |
Subscriber (const URI &uri, Receiver &shared) | |
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... | |
Receiver (Receiver &&) | |
Receiver & | operator= (Receiver &&) |
bool | receive (const uint32_t timeout=TIMEOUT_INDEFINITE) |
Receive at least one event from all shared receivers. More... | |
Additional Inherited Members |
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 34 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 |
Create a subscriber which subscribes to specific publishers.
Postconditions:
uris | publisher URIs in the format [scheme://]*|host|IP|IF:port |
std::runtime_error | if an URI is not fully qualified |
|
explicit |
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 publishers on the given URIs.
uris | publisher URIs 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.
|
inlineexplicit |
shared |
Definition at line 110 of file subscriber.h.
References getSession(), subscribe(), and unsubscribe().
const std::string& zeroeq::Subscriber::getSession | ( | ) | const |
Referenced by Subscriber().
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() |
Referenced by Subscriber().
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() |
Referenced by Subscriber().