SNode.C
Loading...
Searching...
No Matches
GroupsManager.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef WEB_WEBSOCKET_SERVER_CHANNELMANAGER_H
21#define WEB_WEBSOCKET_SERVER_CHANNELMANAGER_H
22
23namespace web::websocket::server {
24 class SubProtocol;
25} // namespace web::websocket::server
26
27#ifndef DOXYGEN_SHOULD_SKIP_THIS
28
29#include <cstddef>
30#include <functional>
31#include <map>
32#include <set>
33#include <string>
34
35#endif /* DOXYGEN_SHOULD_SKIP_THIS */
36
37namespace web::websocket::server {
38
40 public:
41 GroupsManager() = default;
42 GroupsManager(const GroupsManager&) = delete;
43
45
46 private:
48
49 public:
50 static GroupsManager* instance();
51
52 void subscribe(SubProtocol* subProtocol, std::string group = "");
53 void unsubscribe(SubProtocol* subProtocol);
54
55 void sendBroadcast(const std::string& group, const char* message, std::size_t messageLength, const SubProtocol* excludedClient);
56 void sendBroadcast(const std::string& group, const std::string& message, const SubProtocol* excludedClient);
57
58 void
59 sendBroadcastStart(const std::string& group, const char* message, std::size_t messageLength, const SubProtocol* excludedClient);
60 void sendBroadcastStart(const std::string& group, const std::string& message, const SubProtocol* excludedClient);
61
62 void
63 sendBroadcastFrame(const std::string& group, const char* message, std::size_t messageLength, const SubProtocol* excludedClient);
64 void sendBroadcastFrame(const std::string& group, const std::string& message, const SubProtocol* excludedClient);
65
66 void sendBroadcastEnd(const std::string& group, const char* message, std::size_t messageLength, const SubProtocol* excludedClient);
67 void sendBroadcastEnd(const std::string& group, const std::string& message, const SubProtocol* excludedClient);
68
69 void forEachClient(const std::string& group,
70 const std::function<void(const SubProtocol*)>& sendToClient,
71 const SubProtocol* excludedClient);
72
74
75 private:
77 };
78
79} // namespace web::websocket::server
80
81#endif // WEB_WEBSOCKET_SERVER_CHANNELMANAGER_H
std::map< std::string, std::set< SubProtocol * > > groups
static GroupsManager * groupsManager
void sendBroadcast(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 sendBroadcastFrame(const std::string &group, const std::string &message, const SubProtocol *excludedClient)
void sendBroadcastStart(const std::string &group, const std::string &message, const SubProtocol *excludedClient)
GroupsManager & operator=(const GroupsManager &)=delete
void forEachClient(const std::string &group, const std::function< void(const SubProtocol *)> &sendToClient, const SubProtocol *excludedClient)
void sendBroadcastStart(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)
GroupsManager(const GroupsManager &)=delete
void subscribe(SubProtocol *subProtocol, std::string group="")
void sendBroadcastEnd(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 unsubscribe(SubProtocol *subProtocol)
void sendBroadcastFrame(const std::string &group, const char *message, std::size_t messageLength, const SubProtocol *excludedClient)