WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::net::WebSocketServer Class Reference

Dedicated WebSocket server. More...

#include <wpi/net/WebSocketServer.hpp>

Inheritance diagram for wpi::net::WebSocketServer:

Classes

struct  ServerOptions
 Server options. More...

Public Member Functions

 WebSocketServer (uv::Stream &stream, std::span< const std::string_view > protocols, ServerOptions options, const private_init &)
 Private constructor.

Static Public Member Functions

static std::shared_ptr< WebSocketServerCreate (uv::Stream &stream, std::span< const std::string_view > protocols={}, const ServerOptions &options={})
 Starts a dedicated WebSocket server on the provided connection.
static std::shared_ptr< WebSocketServerCreate (uv::Stream &stream, std::initializer_list< std::string_view > protocols, const ServerOptions &options={})
 Starts a dedicated WebSocket server on the provided connection.

Public Attributes

wpi::util::sig::Signal< std::string_view, WebSocket & > connected
 Connected event.

Detailed Description

Dedicated WebSocket server.

Constructor & Destructor Documentation

◆ WebSocketServer()

wpi::net::WebSocketServer::WebSocketServer ( uv::Stream & stream,
std::span< const std::string_view > protocols,
ServerOptions options,
const private_init &  )

Private constructor.

Member Function Documentation

◆ Create() [1/2]

std::shared_ptr< WebSocketServer > wpi::net::WebSocketServer::Create ( uv::Stream & stream,
std::initializer_list< std::string_view > protocols,
const ServerOptions & options = {} )
inlinestatic

Starts a dedicated WebSocket server on the provided connection.

The connection should be an accepted client stream. This also sets the stream user data to the socket server. A connected event is emitted when the connection is opened.

Parameters
streamConnection stream
protocolsAcceptable subprotocols
optionsHandshake options

◆ Create() [2/2]

std::shared_ptr< WebSocketServer > wpi::net::WebSocketServer::Create ( uv::Stream & stream,
std::span< const std::string_view > protocols = {},
const ServerOptions & options = {} )
static

Starts a dedicated WebSocket server on the provided connection.

The connection should be an accepted client stream. This also sets the stream user data to the socket server. A connected event is emitted when the connection is opened.

Parameters
streamConnection stream
protocolsAcceptable subprotocols
optionsHandshake options

Member Data Documentation

◆ connected

wpi::util::sig::Signal<std::string_view, WebSocket&> wpi::net::WebSocketServer::connected

Connected event.

First parameter is the URL, second is the websocket.


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