SNode.C
Loading...
Searching...
No Matches
SubProtocolFactorySelector.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_SUBPROTOCOLSELECTOR_H
21#define WEB_WEBSOCKET_SERVER_SUBPROTOCOLSELECTOR_H
22
23#include "web/websocket/SubProtocolFactorySelector.h"
24
25namespace web::websocket {
26 template <typename SubProtocolT>
28
29 namespace server {
30 class SubProtocol;
31 } // namespace server
32} // namespace web::websocket
33
34#ifndef DOXYGEN_SHOULD_SKIP_THIS
35
36#include <string>
37
38#endif /* DOXYGEN_SHOULD_SKIP_THIS */
39
40namespace web::websocket::server {
41
42 class SubProtocolFactorySelector
43 : public web::websocket::SubProtocolFactorySelector<web::websocket::SubProtocolFactory<web::websocket::server::SubProtocol>> {
44 public:
45 SubProtocolFactorySelector(const SubProtocolFactorySelector&) = delete;
46
47 SubProtocolFactorySelector& operator=(const SubProtocolFactorySelector&) = delete;
48
49 private:
50 using Super = web::websocket::SubProtocolFactorySelector<web::websocket::SubProtocolFactory<web::websocket::server::SubProtocol>>;
51
52 public:
53 static SubProtocolFactorySelector* instance();
54
55 ~SubProtocolFactorySelector() override;
56
57 static void allowDlOpen();
58
59 template <typename SubProtocolFactory>
60 static void link(const std::string& subProtocolName, SubProtocolFactory* (*getSubProtocolFactory)()) {
61 SubProtocolFactorySelector::instance()->Super::link(subProtocolName, getSubProtocolFactory);
62 }
63
64 private:
65 SubProtocolFactory* load(const std::string& subProtocolName) override;
66
67 SubProtocolFactorySelector() = default;
68 };
69
70} // namespace web::websocket::server
71
72extern template class web::websocket::SubProtocolFactorySelector<web::websocket::SubProtocolFactory<web::websocket::server::SubProtocol>>;
73
74#endif // WEB_WEBSOCKET_SERVER_SUBPROTOCOLSELECTOR_H
SocketContextUpgrade(core::socket::stream::SocketConnection *socketConnection, web::http::SocketContextUpgradeFactory< web::http::server::Request, web::http::server::Response > *socketContextUpgradeFactory)
web::websocket::SubProtocolFactory< SubProtocol > * subProtocolFactory
std::string loadSubProtocol(const std::list< std::string > &subProtocolNames)