8 #ifndef WPIUTIL_WPI_WEBSOCKETSERVER_H_
9 #define WPIUTIL_WPI_WEBSOCKETSERVER_H_
16 #include "wpi/ArrayRef.h"
17 #include "wpi/HttpParser.h"
18 #include "wpi/Signal.h"
19 #include "wpi/SmallString.h"
20 #include "wpi/SmallVector.h"
21 #include "wpi/StringRef.h"
22 #include "wpi/WebSocket.h"
70 bool IsUpgrade()
const {
return m_gotHost && m_websocket; }
78 bool m_gotHost =
false;
79 bool m_websocket =
false;
89 struct private_init {};
124 static std::shared_ptr<WebSocketServer>
Create(
126 const ServerOptions& options = ServerOptions{});
138 ServerOptions m_options;
139 bool m_aborted =
false;
142 void Abort(uint16_t code,
StringRef reason);
147 #endif // WPIUTIL_WPI_WEBSOCKETSERVER_H_
std::shared_ptr< WebSocket > Accept(uv::Stream &stream, StringRef protocol=StringRef{})
Accept the upgrade.
Definition: WebSocketServer.h:65
static std::shared_ptr< WebSocket > CreateServer(uv::Stream &stream, StringRef key, StringRef version, StringRef protocol=StringRef{})
Starts a server connection by performing the initial server side handshake.
static std::shared_ptr< WebSocketServer > Create(uv::Stream &stream, ArrayRef< StringRef > protocols=ArrayRef< StringRef >{}, const ServerOptions &options=ServerOptions{})
Starts a dedicated WebSocket server on the provided connection.
WebSocketServer(uv::Stream &stream, ArrayRef< StringRef > protocols, const ServerOptions &options, const private_init &)
Private constructor.
std::function< bool(StringRef)> checkHost
Checker for Host header.
Definition: WebSocketServer.h:106
Server options.
Definition: WebSocketServer.h:95
std::function< bool(StringRef)> checkUrl
Checker for URL.
Definition: WebSocketServer.h:100
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Stream handle.
Definition: Stream.h:68
Dedicated WebSocket server.
Definition: WebSocketServer.h:88
A Connection object allows interaction with an ongoing slot connection.
Definition: Signal.h:198
WebSocketServerHelper(HttpParser &req)
Constructor.
sig::Signal< StringRef, WebSocket & > connected
Connected event.
Definition: WebSocketServer.h:131
sig::Signal upgrade
Upgrade event.
Definition: WebSocketServer.h:75
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
HTTP protocol parser.
Definition: HttpParser.h:25
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
bool IsWebsocket() const
Get whether or not this was a websocket upgrade.
Definition: WebSocketServer.h:46
std::pair< bool, StringRef > MatchProtocol(ArrayRef< StringRef > protocols)
Try to find a match to the list of sub-protocols provided by the client.
WebSocket HTTP server helper.
Definition: WebSocketServer.h:34