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_CLIENT_SUBPROTOCOLSELECTOR_H
21#define WEB_WEBSOCKET_CLIENT_SUBPROTOCOLSELECTOR_H
22
23#include "web/websocket/SubProtocolFactorySelector.h"
24
25namespace web::websocket {
26 template <typename SubProtocolT>
28
29 namespace client {
30 class SubProtocol;
31 } // namespace client
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::client {
41
44 public:
46
48
49 private:
50 using Super = web::websocket::SubProtocolFactorySelector<web::websocket::SubProtocolFactory<web::websocket::client::SubProtocol>>;
51
52 public:
54
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:
66
68 };
69
70} // namespace web::websocket::client
71
72extern template class web::websocket::SubProtocolFactorySelector<web::websocket::SubProtocolFactory<web::websocket::client::SubProtocol>>;
73
74#endif // WEB_WEBSOCKET_CLIENT_SUBPROTOCOLSELECTOR_H
void sendClose(uint16_t statusCode=1000, const char *reason=nullptr, std::size_t reasonLength=0) override
void sendPing(const char *reason=nullptr, std::size_t reasonLength=0) override
~SocketContextUpgrade() override=default
void onMessageData(const char *chunk, uint64_t chunkLen) override
SocketContextUpgrade(const SocketContextUpgrade &)=delete
SocketContextUpgrade & operator=(const SocketContextUpgrade &)=delete
void sendMessage(uint8_t opCode, const char *message, std::size_t messageLength) override
void sendClose(const char *message, std::size_t messageLength) override
void sendMessageFrame(const char *message, std::size_t messageLength) override
void sendMessageEnd(const char *message, std::size_t messageLength) override
SocketContextUpgrade(core::socket::stream::SocketConnection *socketConnection, web::http::SocketContextUpgradeFactory< Request, Response > *socketContextUpgradeFactory, Role role)
void sendPong(const char *reason=nullptr, std::size_t reasonLength=0) override
void sendMessageStart(uint8_t opCode, const char *message, std::size_t messageLength) override
core::socket::stream::SocketConnection * getSocketConnection() override
void onMessageError(uint16_t errnum) override
virtual void sendMessage(uint8_t opCode, const char *message, std::size_t messageLength)=0
virtual void sendPing(const char *reason=nullptr, std::size_t reasonLength=0)=0
virtual void sendMessageFrame(const char *message, std::size_t messageLength)=0
SubProtocolContext & operator=(const SubProtocolContext &)=delete
virtual void sendPong(const char *reason=nullptr, std::size_t reasonLength=0)=0
virtual void sendClose(const char *message, std::size_t messageLength)=0
SubProtocolContext(core::socket::stream::SocketConnection *socketConnection, bool role)
virtual void sendMessageEnd(const char *message, std::size_t messageLength)=0
virtual void sendClose(uint16_t statusCode=1000, const char *reason=nullptr, std::size_t reasonLength=0)=0
virtual void sendMessageStart(uint8_t opCode, const char *message, std::size_t messageLength)=0
virtual core::socket::stream::SocketConnection * getSocketConnection()=0
SubProtocolContext(const SubProtocolContext &)=delete
void sendMessageEnd(const char *message, std::size_t messageLength)
void sendFrameData(const char *frame, uint64_t frameLength) const
Transmitter & operator=(const Transmitter &)=delete
std::random_device randomDevice
Definition Transmitter.h:68
void sendFrameData(uint8_t data) const
void sendFrameData(uint16_t data) const
void sendMessage(uint8_t opCode, const char *message, std::size_t messageLength)
void sendFrameData(uint32_t data) const
Transmitter(core::socket::stream::SocketConnection *socketConnection, bool masking)
core::socket::stream::SocketConnection * socketConnection
Definition Transmitter.h:71
void send(bool end, uint8_t opCode, const char *message, std::size_t messageLength)
void sendFrame(bool fin, uint8_t opCode, const char *payload, uint64_t payloadLength)
void sendFrameData(uint64_t data) const
std::uniform_int_distribution< uint32_t > distribution
Definition Transmitter.h:69
Transmitter(const Transmitter &)=delete
void sendMessageStart(uint8_t opCode, const char *message, std::size_t messageLength)
void sendMessageFrame(const char *message, std::size_t messageLength)
web::websocket::SubProtocolFactory< SubProtocol > * subProtocolFactory
std::string loadSubProtocol(const std::string &subProtocolName)
SocketContextUpgrade(core::socket::stream::SocketConnection *socketConnection, web::http::SocketContextUpgradeFactory< web::http::client::Request, web::http::client::Response > *socketContextUpgradeFactory)
SubProtocolFactory * load(const std::string &subProtocolName) override
SubProtocolFactorySelector(const SubProtocolFactorySelector &)=delete
SubProtocolFactorySelector & operator=(const SubProtocolFactorySelector &)=delete
static void link(const std::string &subProtocolName, SubProtocolFactory *(*getSubProtocolFactory)())
#define CLOSE_SOCKET_TIMEOUT