This class template presents an unnamed topic.
More...
#include <drogon/PubSubService.h>
|
|
using | MessageHandler = std::function<void(const MessageType &)> |
|
using | SharedMutex = std::shared_timed_mutex |
|
| void | publish (const MessageType &message) const |
| | Publish a message, every subscriber in the topic will receive the message.
|
| SubscriberID | subscribe (const MessageHandler &handler) |
| | Subscribe to the topic.
|
| SubscriberID | subscribe (MessageHandler &&handler) |
| | Subscribe to the topic.
|
|
void | unsubscribe (SubscriberID id) |
| | Unsubscribe from the topic.
|
| bool | empty () const |
| | Check if the topic is empty.
|
|
void | clear () |
| | Remove all subscribers from the topic.
|
template<typename MessageType>
class drogon::Topic< MessageType >
This class template presents an unnamed topic.
- Template Parameters
-
◆ empty()
template<typename MessageType>
Check if the topic is empty.
- Returns
- true means there are no subscribers.
-
false means there are subscribers in the topic.
◆ publish()
template<typename MessageType>
| void drogon::Topic< MessageType >::publish |
( |
const MessageType & | message | ) |
const |
|
inline |
Publish a message, every subscriber in the topic will receive the message.
- Parameters
-
◆ subscribe() [1/2]
template<typename MessageType>
| SubscriberID drogon::Topic< MessageType >::subscribe |
( |
const MessageHandler & | handler | ) |
|
|
inline |
Subscribe to the topic.
- Parameters
-
| handler | is invoked when a message arrives. |
- Returns
- SubscriberID
◆ subscribe() [2/2]
template<typename MessageType>
| SubscriberID drogon::Topic< MessageType >::subscribe |
( |
MessageHandler && | handler | ) |
|
|
inline |
Subscribe to the topic.
- Parameters
-
| handler | is invoked when a message arrives. |
- Returns
- SubscriberID
The documentation for this class was generated from the following file: