SNode.C
Loading...
Searching...
No Matches
web::websocket::client::SocketContextUpgradeFactory Class Reference

#include <SocketContextUpgradeFactory.h>

Inheritance diagram for web::websocket::client::SocketContextUpgradeFactory:
Collaboration diagram for web::websocket::client::SocketContextUpgradeFactory:

Public Member Functions

 SocketContextUpgradeFactory ()=default
Public Member Functions inherited from web::http::client::SocketContextUpgradeFactory
void checkRefCount () final
Public Member Functions inherited from core::socket::stream::SocketContextFactory
 SocketContextFactory (SocketContextFactory &)=delete
 SocketContextFactory (SocketContextFactory &&)=delete
SocketContextFactoryoperator= (SocketContextFactory &)=delete
SocketContextFactoryoperator= (SocketContextFactory &&)=delete
virtual core::socket::stream::SocketContextcreate (core::socket::stream::SocketConnection *socketConnection)=0

Static Public Member Functions

static void link ()
Static Public Member Functions inherited from web::http::client::SocketContextUpgradeFactory
static void link (const std::string &upgradeContextName, SocketContextUpgradeFactory *(*linkedPlugin)())

Private Member Functions

void prepare (web::http::client::Request &request) override
std::string name () override
http::SocketContextUpgrade< web::http::client::Request, web::http::client::Response > * create (core::socket::stream::SocketConnection *socketConnection, web::http::client::Request *request, web::http::client::Response *response) override

Additional Inherited Members

Public Types inherited from web::http::client::SocketContextUpgradeFactory
using Resquest = web::http::client::Request
using Reponse = web::http::client::Response
Public Types inherited from web::http::SocketContextUpgradeFactory< web::http::client::Request, web::http::client::Response >
using Request
using Response
Protected Member Functions inherited from web::http::client::SocketContextUpgradeFactory
 SocketContextUpgradeFactory ()
Protected Member Functions inherited from web::http::SocketContextUpgradeFactory< web::http::client::Request, web::http::client::Response >
 SocketContextUpgradeFactory ()=default
 ~SocketContextUpgradeFactory () override=default
void prepare (Request &request, Response &response)
Protected Member Functions inherited from core::socket::stream::SocketContextFactory
 SocketContextFactory ()=default
virtual ~SocketContextFactory ()
Protected Attributes inherited from web::http::SocketContextUpgradeFactory< web::http::client::Request, web::http::client::Response >
std::size_t refCount

Detailed Description

Definition at line 55 of file SocketContextUpgradeFactory.h.

Constructor & Destructor Documentation

◆ SocketContextUpgradeFactory()

web::websocket::client::SocketContextUpgradeFactory::SocketContextUpgradeFactory ( )
default

Referenced by web::websocket::client::websocketClientSocketContextUpgradeFactory().

Here is the caller graph for this function:

Member Function Documentation

◆ create()

http::SocketContextUpgrade< web::http::client::Request, web::http::client::Response > * web::websocket::client::SocketContextUpgradeFactory::create ( core::socket::stream::SocketConnection * socketConnection,
web::http::client::Request * request,
web::http::client::Response * response )
overrideprivatevirtual

Implements web::http::SocketContextUpgradeFactory< web::http::client::Request, web::http::client::Response >.

Definition at line 99 of file SocketContextUpgradeFactory.cpp.

101 {
102 SocketContextUpgrade* socketContext = nullptr;
103
104 if (response->get("sec-websocket-accept") == base64::serverWebSocketKey(request->header("Sec-WebSocket-Key"))) {
105 const std::string subProtocolName = response->get("sec-websocket-protocol");
106
107 socketContext = new SocketContextUpgrade(socketConnection, this);
108 const std::string selectedSubProtocolName = socketContext->loadSubProtocol(subProtocolName);
109
110 if (selectedSubProtocolName.empty()) {
111 delete socketContext;
112 socketContext = nullptr;
113 }
114 } else {
116 }
117
118 return socketContext;
119 }
std::string serverWebSocketKey(const std::string &clientWebSocketKey)
Definition base64.cpp:56

References web::http::client::SocketContextUpgradeFactory::checkRefCount(), web::http::client::Response::get(), web::http::client::Request::header(), web::websocket::client::SocketContextUpgrade::loadSubProtocol(), base64::serverWebSocketKey(), and web::websocket::client::SocketContextUpgrade::SocketContextUpgrade().

Here is the call graph for this function:

◆ link()

void web::websocket::client::SocketContextUpgradeFactory::link ( )
static

Definition at line 121 of file SocketContextUpgradeFactory.cpp.

121 {
122 static bool linked = false;
123
124 if (!linked) {
126 linked = true;
127 }
128 }
static void link(const std::string &upgradeContextName, SocketContextUpgradeFactory *(*linkedPlugin)())
web::http::client::SocketContextUpgradeFactory * websocketClientSocketContextUpgradeFactory()

References web::http::client::SocketContextUpgradeFactory::link(), and web::websocket::client::websocketClientSocketContextUpgradeFactory().

Here is the call graph for this function:

◆ name()

std::string web::websocket::client::SocketContextUpgradeFactory::name ( )
overrideprivatevirtual

◆ prepare()

void web::websocket::client::SocketContextUpgradeFactory::prepare ( web::http::client::Request & request)
overrideprivatevirtual

Implements web::http::client::SocketContextUpgradeFactory.

Definition at line 86 of file SocketContextUpgradeFactory.cpp.

86 {
87 unsigned char ebytes[16];
88 getentropy(ebytes, 16);
89
90 request.set("Sec-WebSocket-Key", base64::base64_encode(ebytes, 16));
91 request.set("Sec-WebSocket-Version", "13");
92 }
std::string base64_encode(const unsigned char *bytes_to_encode, std::size_t length)
Definition base64.cpp:69
int getentropy(void *buf, size_t buflen)

References base64::base64_encode(), web::websocket::client::getentropy(), and web::http::client::Request::set().

Here is the call graph for this function:

The documentation for this class was generated from the following files: