WPILibC++
2019.1.1-beta-4-27-ga2368a6
|
WebSocket HTTP server helper. More...
#include <WebSocketServer.h>
Public Member Functions | |
WebSocketServerHelper (HttpParser &req) | |
Constructor. More... | |
bool | IsWebsocket () const |
Get whether or not this was a websocket upgrade. More... | |
std::pair< bool, StringRef > | MatchProtocol (ArrayRef< StringRef > protocols) |
Try to find a match to the list of sub-protocols provided by the client. More... | |
std::shared_ptr< WebSocket > | Accept (uv::Stream &stream, StringRef protocol=StringRef{}) |
Accept the upgrade. More... | |
bool | IsUpgrade () const |
Public Attributes | |
sig::Signal | upgrade |
Upgrade event. More... | |
WebSocket HTTP server helper.
Handles websocket-specific headers. User must provide the HttpParser.
|
explicit |
Constructor.
req | HttpParser for request |
|
inline |
Accept the upgrade.
Disconnect other readers (such as the HttpParser reader) before calling this. See also WebSocket::CreateServer().
stream | Connection stream |
protocol | The subprotocol to send to the client |
|
inline |
Get whether or not this was a websocket upgrade.
Only valid during and after the upgrade event.
std::pair<bool, StringRef> wpi::WebSocketServerHelper::MatchProtocol | ( | ArrayRef< StringRef > | protocols | ) |
Try to find a match to the list of sub-protocols provided by the client.
The list is priority ordered, so the first match wins. Only valid during and after the upgrade event.
protocols | Acceptable protocols |
sig::Signal wpi::WebSocketServerHelper::upgrade |
Upgrade event.
Call Accept() to accept the upgrade.