5#ifndef WPINET_HTTPWEBSOCKETSERVERCONNECTION_H_
6#define WPINET_HTTPWEBSOCKETSERVERCONNECTION_H_
8#include <initializer_list>
28template <
typename Derived>
31 public std::enable_shared_from_this<Derived> {
40 std::span<const std::string_view> protocols)
43 m_protocols{protocols.begin(), protocols.end()} {
49 std::string_view protocol = m_helper.
MatchProtocol(protocols).second;
62 auto self = this->shared_from_this();
85 std::shared_ptr<uv::Stream> stream,
86 std::initializer_list<std::string_view> protocols)
88 {protocols.begin(), protocols.end()}) {}
This file defines the SmallVector class.
Definition HttpServerConnection.h:19
sig::ScopedConnection m_dataConn
The header reader connection.
Definition HttpServerConnection.h:141
uv::Stream & m_stream
The underlying stream for the connection.
Definition HttpServerConnection.h:138
HttpParser m_request
The HTTP request.
Definition HttpServerConnection.h:129
sig::Connection m_messageCompleteConn
The message complete connection.
Definition HttpServerConnection.h:147
A server-side HTTP connection that also accepts WebSocket upgrades.
Definition HttpWebSocketServerConnection.h:31
virtual void ProcessWsUpgrade()=0
Process an incoming WebSocket upgrade.
virtual bool IsValidWsUpgrade(std::string_view protocol)
Check that an incoming WebSocket upgrade is okay.
Definition HttpWebSocketServerConnection.h:100
HttpWebSocketServerConnection(std::shared_ptr< uv::Stream > stream, std::span< const std::string_view > protocols)
Constructor.
Definition HttpWebSocketServerConnection.h:39
WebSocket * m_websocket
WebSocket connection; not valid until ProcessWsUpgrade is called.
Definition HttpWebSocketServerConnection.h:118
HttpWebSocketServerConnection(std::shared_ptr< uv::Stream > stream, std::initializer_list< std::string_view > protocols)
Constructor.
Definition HttpWebSocketServerConnection.h:84
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1212
iterator begin()
Definition SmallVector.h:283
iterator end()
Definition SmallVector.h:285
RFC 6455 compliant WebSocket client and server implementation.
Definition WebSocket.h:34
WebSocket HTTP server helper.
Definition WebSocketServer.h:33
sig::Signal upgrade
Upgrade event.
Definition WebSocketServer.h:89
std::shared_ptr< WebSocket > Accept(uv::Stream &stream, std::string_view protocol={})
Accept the upgrade.
Definition WebSocketServer.h:79
std::pair< bool, std::string_view > MatchProtocol(std::span< const std::string_view > protocols)
Try to find a match to the list of sub-protocols provided by the client.
bool disconnect() noexcept
Definition Signal.h:217
void connect(Callable &&c)
Connect a callable of compatible arguments.
Definition Signal.h:586
Foonathan namespace.
Definition ntcore_cpp.h:26