#include <GroupsManager.h>
|
| GroupsManager ()=default |
|
| GroupsManager (const GroupsManager &)=delete |
|
GroupsManager & | operator= (const GroupsManager &)=delete |
|
void | subscribe (SubProtocol *subProtocol, std::string group="") |
|
void | unsubscribe (SubProtocol *subProtocol) |
|
void | sendBroadcast (const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient) |
|
void | sendBroadcast (const std::string &group, const std::string &message, const SubProtocol *excludedClient) |
|
void | sendBroadcastStart (const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient) |
|
void | sendBroadcastStart (const std::string &group, const std::string &message, const SubProtocol *excludedClient) |
|
void | sendBroadcastFrame (const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient) |
|
void | sendBroadcastFrame (const std::string &group, const std::string &message, const SubProtocol *excludedClient) |
|
void | sendBroadcastEnd (const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient) |
|
void | sendBroadcastEnd (const std::string &group, const std::string &message, const SubProtocol *excludedClient) |
|
void | forEachClient (const std::string &group, const std::function< void(const SubProtocol *)> &sendToClient, const SubProtocol *excludedClient) |
|
Definition at line 39 of file GroupsManager.h.
◆ GroupsManager() [1/2]
web::websocket::server::GroupsManager::GroupsManager |
( |
| ) |
|
|
default |
◆ GroupsManager() [2/2]
web::websocket::server::GroupsManager::GroupsManager |
( |
const GroupsManager & | | ) |
|
|
delete |
◆ ~GroupsManager()
web::websocket::server::GroupsManager::~GroupsManager |
( |
| ) |
|
|
private |
◆ forEachClient()
void web::websocket::server::GroupsManager::forEachClient |
( |
const std::string & | group, |
|
|
const std::function< void(const SubProtocol *)> & | sendToClient, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 145 of file GroupsManager.cpp.
147 {
148 if (
groups.contains(group)) {
149 for (
const SubProtocol* client :
groups[group]) {
150 if (client != excludedClient) {
151 sendToClient(client);
152 }
153 }
154 }
155 }
std::map< std::string, std::set< SubProtocol * > > groups
◆ instance()
GroupsManager * web::websocket::server::GroupsManager::instance |
( |
| ) |
|
|
static |
◆ operator=()
◆ sendBroadcast() [1/2]
void web::websocket::server::GroupsManager::sendBroadcast |
( |
const std::string & | group, |
|
|
const char * | message, |
|
|
std::size_t | messageLength, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 71 of file GroupsManager.cpp.
74 {
75 if (
groups.contains(group)) {
76 for (
const SubProtocol* client :
groups[group]) {
77 if (client != excludedClient) {
78 client->sendMessage(message, messageLength);
79 }
80 }
81 }
82 }
◆ sendBroadcast() [2/2]
void web::websocket::server::GroupsManager::sendBroadcast |
( |
const std::string & | group, |
|
|
const std::string & | message, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 84 of file GroupsManager.cpp.
84 {
85 if (
groups.contains(group)) {
86 for (
const SubProtocol* client :
groups[group]) {
87 if (client != excludedClient) {
88 client->sendMessage(message);
89 }
90 }
91 }
92 }
◆ sendBroadcastEnd() [1/2]
void web::websocket::server::GroupsManager::sendBroadcastEnd |
( |
const std::string & | group, |
|
|
const char * | message, |
|
|
std::size_t | messageLength, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 128 of file GroupsManager.cpp.
131 {
132 if (
groups.contains(group)) {
133 for (
const SubProtocol* client :
groups[group]) {
134 if (client != excludedClient) {
135 client->sendMessageEnd(message, messageLength);
136 }
137 }
138 }
139 }
◆ sendBroadcastEnd() [2/2]
void web::websocket::server::GroupsManager::sendBroadcastEnd |
( |
const std::string & | group, |
|
|
const std::string & | message, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 141 of file GroupsManager.cpp.
141 {
143 }
void sendBroadcastEnd(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)
◆ sendBroadcastFrame() [1/2]
void web::websocket::server::GroupsManager::sendBroadcastFrame |
( |
const std::string & | group, |
|
|
const char * | message, |
|
|
std::size_t | messageLength, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 111 of file GroupsManager.cpp.
114 {
115 if (
groups.contains(group)) {
116 for (
const SubProtocol* client :
groups[group]) {
117 if (client != excludedClient) {
118 client->sendMessageFrame(message, messageLength);
119 }
120 }
121 }
122 }
◆ sendBroadcastFrame() [2/2]
void web::websocket::server::GroupsManager::sendBroadcastFrame |
( |
const std::string & | group, |
|
|
const std::string & | message, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 124 of file GroupsManager.cpp.
124 {
126 }
void sendBroadcastFrame(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)
◆ sendBroadcastStart() [1/2]
void web::websocket::server::GroupsManager::sendBroadcastStart |
( |
const std::string & | group, |
|
|
const char * | message, |
|
|
std::size_t | messageLength, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 94 of file GroupsManager.cpp.
97 {
98 if (
groups.contains(group)) {
99 for (
const SubProtocol* client :
groups[group]) {
100 if (client != excludedClient) {
101 client->sendMessageStart(message, messageLength);
102 }
103 }
104 }
105 }
◆ sendBroadcastStart() [2/2]
void web::websocket::server::GroupsManager::sendBroadcastStart |
( |
const std::string & | group, |
|
|
const std::string & | message, |
|
|
const SubProtocol * | excludedClient ) |
Definition at line 107 of file GroupsManager.cpp.
107 {
109 }
void sendBroadcastStart(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)
◆ subscribe()
void web::websocket::server::GroupsManager::subscribe |
( |
SubProtocol * | subProtocol, |
|
|
std::string | group = "" ) |
Definition at line 40 of file GroupsManager.cpp.
40 {
41 if (group.empty()) {
42 group = subProtocol->getName();
43 }
44
45 if (subProtocol->group != group) {
46 const std::string newChannel = subProtocol->getName() + "/" + group;
47
48 groups[newChannel].insert(subProtocol);
49
50 if (!subProtocol->group.empty()) {
52 }
53
54 subProtocol->group = newChannel;
55 }
56 }
void unsubscribe(SubProtocol *subProtocol)
References web::websocket::server::SubProtocol::group, and unsubscribe().
◆ unsubscribe()
void web::websocket::server::GroupsManager::unsubscribe |
( |
SubProtocol * | subProtocol | ) |
|
Definition at line 58 of file GroupsManager.cpp.
58 {
59 if (
groups.contains(subProtocol->group)) {
60 groups[subProtocol->group].erase(subProtocol);
61
62 if (
groups[subProtocol->group].empty()) {
63 groups.erase(subProtocol->group);
65 delete this;
66 }
67 }
68 }
69 }
Referenced by subscribe().
◆ groups
std::map<std::string, std::set<SubProtocol*> > web::websocket::server::GroupsManager::groups |
|
private |
◆ groupsManager
GroupsManager * web::websocket::server::GroupsManager::groupsManager = nullptr |
|
static |
The documentation for this class was generated from the following files: