12#include <unordered_map>
13#include <shared_mutex>
22 return [ptr, method](
const std::string& s) {
41 void subscribe(
const std::string& groupName, std::function<
void(
const std::string&)> callback,
const std::string& CUID);
48 void unsubscribe(
const std::string& groupName ,
const std::string& CUID);
56 void send(
const std::string& groupName,
const std::string& message);
64 std::unordered_map<std::string, std::vector<std::pair<std::function<void(
const std::string&)>, std::string>>>
groups;
68 GroupManager() =
default;
69 ~GroupManager() =
default;
72 std::shared_mutex mtx;
75 GroupManager(
const GroupManager&) =
delete;
76 GroupManager& operator=(
const GroupManager&) =
delete;
77 GroupManager(GroupManager&&) =
delete;
78 GroupManager& operator=(GroupManager&&) =
delete;
auto createCallback(T *ptr, void(T::*method)(const std::string &))
Project NSCpp.
Definition GroupManager.h:21
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.
static GroupManager & getInstance()
Return the instance of the GroupManager or create one if it does not exist.
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.
Definition GroupManager.h:64