#include <GroupManager.h>
|
| void | subscribe (const std::string &groupName, std::function< void(const std::string &)> callback, const std::string &CUID) |
| | Let you register a Channel's callback to a group.
|
| |
| void | unsubscribe (const std::string &groupName, const std::string &CUID) |
| | Remove a Channel's callback from the given group.
|
| |
| void | send (const std::string &groupName, const std::string &message) |
| | Emit the message in the given groupName.
|
| |
|
| std::unordered_map< std::string, std::vector< std::pair< std::function< void(const std::string &)>, std::string > > > | groups |
| | Unordered map of the groups, link the group's name to the callback and CUID.
|
| |
◆ getInstance()
Return the instance of the GroupManager or create one if it does not exist.
This class is a Singleton.
◆ send()
| void GroupManager::send |
( |
const std::string & | groupName, |
|
|
const std::string & | message ) |
Emit the message in the given groupName.
Every callbacks of the given group will be called with the message as parameter.
- Parameters
-
| groupName | Group's name. |
| message | Message to be emit the group. |
◆ subscribe()
| void GroupManager::subscribe |
( |
const std::string & | groupName, |
|
|
std::function< void(const std::string &)> | callback, |
|
|
const std::string & | CUID ) |
Let you register a Channel's callback to a group.
- Parameters
-
| groupName | Group's name. |
| callback | Callback which will be called when someone emit in the groupName's group. |
| CUID | Channel's key used to identify it. |
◆ unsubscribe()
| void GroupManager::unsubscribe |
( |
const std::string & | groupName, |
|
|
const std::string & | CUID ) |
Remove a Channel's callback from the given group.
- Parameters
-
| groupName | Group's name to search for the callback. |
| CUID | Channel's key in the group associate to the callback. |
◆ groups
| std::unordered_map<std::string, std::vector<std::pair<std::function<void(const std::string&)>, std::string> > > GroupManager::groups |
|
protected |
Unordered map of the groups, link the group's name to the callback and CUID.
Multiple callbacks can be declared for the same group. When a Channel is unsubscribe, every receiver inside the group is removed.
The documentation for this class was generated from the following file: