5#ifndef WPINET_WEBSOCKETSERVER_H_
6#define WPINET_WEBSOCKETSERVER_H_
9#include <initializer_list>
57 std::span<const std::string_view> protocols);
69 std::initializer_list<std::string_view> protocols) {
80 std::string_view protocol = {}) {
84 bool IsUpgrade()
const {
return m_gotHost && m_websocket; }
92 bool m_gotHost =
false;
93 bool m_websocket =
false;
103 struct private_init {};
127 std::span<const std::string_view> protocols,
139 static std::shared_ptr<WebSocketServer>
Create(
140 uv::Stream& stream, std::span<const std::string_view> protocols = {},
141 const ServerOptions& options = {});
152 static std::shared_ptr<WebSocketServer>
Create(
153 uv::Stream& stream, std::initializer_list<std::string_view> protocols,
155 return Create(stream, {protocols.begin(), protocols.end()}, options);
168 ServerOptions m_options;
169 bool m_aborted =
false;
174 void Abort(uint16_t
code, std::string_view reason);
This file defines the SmallString class.
This file defines the SmallVector class.
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or and nanopb were all modified for use in Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source code
Definition ThirdPartyNotices.txt:123
HTTP protocol parser.
Definition HttpParser.h:24
@ kRequest
Definition HttpParser.h:27
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:27
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1212
static std::shared_ptr< WebSocket > CreateServer(uv::Stream &stream, std::string_view key, std::string_view version, std::string_view protocol={})
Starts a server connection by performing the initial server side handshake.
WebSocket HTTP server helper.
Definition WebSocketServer.h:33
sig::Signal upgrade
Upgrade event.
Definition WebSocketServer.h:89
WebSocketServerHelper(HttpParser &req)
Constructor.
std::shared_ptr< WebSocket > Accept(uv::Stream &stream, std::string_view protocol={})
Accept the upgrade.
Definition WebSocketServer.h:79
bool IsWebsocket() const
Get whether or not this was a websocket upgrade.
Definition WebSocketServer.h:45
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.
std::pair< bool, std::string_view > MatchProtocol(std::initializer_list< std::string_view > protocols)
Try to find a match to the list of sub-protocols provided by the client.
Definition WebSocketServer.h:68
bool IsUpgrade() const
Definition WebSocketServer.h:84
Dedicated WebSocket server.
Definition WebSocketServer.h:102
sig::Signal< std::string_view, WebSocket & > connected
Connected event.
Definition WebSocketServer.h:161
static std::shared_ptr< WebSocketServer > Create(uv::Stream &stream, std::initializer_list< std::string_view > protocols, const ServerOptions &options={})
Starts a dedicated WebSocket server on the provided connection.
Definition WebSocketServer.h:152
static std::shared_ptr< WebSocketServer > Create(uv::Stream &stream, std::span< const std::string_view > protocols={}, const ServerOptions &options={})
Starts a dedicated WebSocket server on the provided connection.
WebSocketServer(uv::Stream &stream, std::span< const std::string_view > protocols, ServerOptions options, const private_init &)
Private constructor.
ScopedConnection is a RAII version of Connection It disconnects the slot from the signal upon destruc...
Definition Signal.h:257
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition Signal.h:495
Stream handle.
Definition Stream.h:68
Foonathan namespace.
Definition ntcore_cpp.h:26
Server options.
Definition WebSocketServer.h:109
std::function< bool(std::string_view)> checkUrl
Checker for URL.
Definition WebSocketServer.h:114
std::function< bool(std::string_view)> checkHost
Checker for Host header.
Definition WebSocketServer.h:120