OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
ossia::net::websocket_server_beast Class Referencefinal

Beast-based WebSocket + HTTP server implementing websocket_server_interface. More...

Inheritance diagram for ossia::net::websocket_server_beast:
ossia::net::websocket_server_interface

Detailed Description

Beast-based WebSocket + HTTP server implementing websocket_server_interface.

Public Member Functions

 websocket_server_beast (ossia::net::network_context_ptr ctx)
 websocket_server_beast implementation
 
void listen (uint16_t port) override
 
void run () override
 
void stop () override
 
void close (ws_connection_handle hdl) override
 
void set_open_handler (ws_open_handler h) override
 
void set_close_handler (ws_close_handler h) override
 
void set_message_handler (ws_server_message_handler h) override
 
std::string get_remote_ip (const ws_connection_handle &hdl) override
 Get the remote IP address of a connected client (e.g. "192.168.1.10").
 
std::string get_remote_endpoint (const ws_connection_handle &hdl) override
 Get the remote endpoint string (e.g. "192.168.1.10:54321").
 
std::string get_local_ip (const ws_connection_handle &hdl) override
 Get the local IP address as seen by a connected client.
 
void send_message (ws_connection_handle hdl, const std::string &message) override
 
void send_message (ws_connection_handle hdl, const server_reply &message) override
 
void send_message (ws_connection_handle hdl, const rapidjson::StringBuffer &message) override
 
void send_binary_message (ws_connection_handle hdl, std::string_view message) override
 

Member Function Documentation

◆ listen()

void ossia::net::websocket_server_beast::listen ( uint16_t  port)
overridevirtual

◆ run()

void ossia::net::websocket_server_beast::run ( )
overridevirtual

◆ stop()

void ossia::net::websocket_server_beast::stop ( )
overridevirtual

◆ close()

void ossia::net::websocket_server_beast::close ( ws_connection_handle  hdl)
overridevirtual

◆ set_open_handler()

void ossia::net::websocket_server_beast::set_open_handler ( ws_open_handler  h)
overridevirtual

◆ set_close_handler()

void ossia::net::websocket_server_beast::set_close_handler ( ws_close_handler  h)
overridevirtual

◆ set_message_handler()

void ossia::net::websocket_server_beast::set_message_handler ( ws_server_message_handler  )
overridevirtual

The message handler is called for both WebSocket messages and HTTP requests. For HTTP requests, the opcode is ws_opcode::text and the payload is the URI. The returned server_reply is sent back to the client.

Implements ossia::net::websocket_server_interface.

◆ get_remote_ip()

std::string ossia::net::websocket_server_beast::get_remote_ip ( const ws_connection_handle &  hdl)
overridevirtual

Get the remote IP address of a connected client (e.g. "192.168.1.10").

Implements ossia::net::websocket_server_interface.

◆ get_remote_endpoint()

std::string ossia::net::websocket_server_beast::get_remote_endpoint ( const ws_connection_handle &  hdl)
overridevirtual

Get the remote endpoint string (e.g. "192.168.1.10:54321").

Implements ossia::net::websocket_server_interface.

◆ get_local_ip()

std::string ossia::net::websocket_server_beast::get_local_ip ( const ws_connection_handle &  hdl)
overridevirtual

Get the local IP address as seen by a connected client.

Implements ossia::net::websocket_server_interface.

◆ send_message() [1/3]

void ossia::net::websocket_server_beast::send_message ( ws_connection_handle  hdl,
const std::string &  message 
)
overridevirtual

◆ send_message() [2/3]

void ossia::net::websocket_server_beast::send_message ( ws_connection_handle  hdl,
const server_reply &  message 
)
overridevirtual

◆ send_message() [3/3]

void ossia::net::websocket_server_beast::send_message ( ws_connection_handle  hdl,
const rapidjson::StringBuffer &  message 
)
overridevirtual

◆ send_binary_message()

void ossia::net::websocket_server_beast::send_binary_message ( ws_connection_handle  hdl,
std::string_view  message 
)
overridevirtual