RESTinio
Namespaces | Classes | Typedefs | Enumerations | Functions
restinio::websocket::basic Namespace Reference

Namespaces

 impl
 

Classes

class  message_t
 WebSocket message. More...
 
class  ws_t
 A WebSocket bind. More...
 

Typedefs

using ws_handle_t = std::shared_ptr< ws_t >
 Alias for ws_t handle. More...
 
using byte_t = unsigned char
 Alias for byte. More...
 
using raw_data_t = std::string
 Bytes buffer. More...
 
using message_handle_t = std::shared_ptr< message_t >
 Request handler, that is the type for calling request handlers. More...
 
using default_message_handler_t = std::function< void(message_handle_t) >
 

Enumerations

enum  opcode_t : std::uint8_t { opcode_t::RESTINIO_WEBSOCKET_OPCODES_GEN, opcode_t::unknown_frame = 0x0F }
 
enum  status_code_t : std::uint16_t {
  status_code_t::normal_closure = 1000, status_code_t::going_away = 1001, status_code_t::protocol_error = 1002, status_code_t::cant_accept_data = 1003,
  status_code_t::no_status_provided = 1005, status_code_t::connection_lost = 1006, status_code_t::invalid_message_data = 1007, status_code_t::policy_violation = 1008,
  status_code_t::too_big_message = 1009, status_code_t::more_extensions_expected = 1010, status_code_t::unexpected_condition = 1011
}
 
enum  activation_t { activation_t::immediate, activation_t::delayed }
 Flags for websocket activation policies. More...
 

Functions

const char * opcode_to_string (opcode_t opcode)
 Helper sunction to get method string name. More...
 
bool is_valid_opcode (opcode_t opcode)
 
std::string status_code_to_bin (status_code_t code)
 
status_code_t status_code_from_bin (std::string data)
 
void activate (ws_t &ws)
 Activate websocket: start receiving messages. More...
 
template<typename Traits , typename WS_Message_Handler >
ws_handle_t upgrade (request_t &req, activation_t activation_flag, http_header_fields_t upgrade_response_header_fields, WS_Message_Handler ws_message_handler)
 Upgrade http-connection of a current request to a websocket connection. More...
 
template<typename Traits , typename WS_Message_Handler >
auto upgrade (request_t &req, activation_t activation_flag, std::string sec_websocket_accept_field_value, WS_Message_Handler ws_message_handler)
 
template<typename Traits , typename WS_Message_Handler >
auto upgrade (request_t &req, activation_t activation_flag, std::string sec_websocket_accept_field_value, std::string sec_websocket_protocol_field_value, WS_Message_Handler ws_message_handler)
 
template<typename Traits , typename WS_Message_Handler >
auto upgrade (request_t &req, activation_t activation_flag, WS_Message_Handler ws_message_handler)
 

Typedef Documentation

◆ byte_t

using restinio::websocket::basic::byte_t = typedef unsigned char

Alias for byte.

Definition at line 31 of file ws_parser.hpp.

◆ default_message_handler_t

Definition at line 212 of file message.hpp.

◆ message_handle_t

using restinio::websocket::basic::message_handle_t = typedef std::shared_ptr< message_t >

Request handler, that is the type for calling request handlers.

Examples:
sample/websocket_detailed/main.cpp.

Definition at line 205 of file message.hpp.

◆ raw_data_t

using restinio::websocket::basic::raw_data_t = typedef std::string

Bytes buffer.

Definition at line 34 of file ws_parser.hpp.

◆ ws_handle_t

typedef std::shared_ptr< ws_t > restinio::websocket::basic::ws_handle_t

Alias for ws_t handle.

Examples:
sample/websocket_detailed/main.cpp.

Definition at line 27 of file ws_connection_base.hpp.

Enumeration Type Documentation

◆ activation_t

Flags for websocket activation policies.

Enumerator
immediate 

Activate immediately after upgrade operation.

delayed 

User will initiate activation later.

Definition at line 198 of file websocket.hpp.

◆ opcode_t

enum restinio::websocket::basic::opcode_t : std::uint8_t
strong
Enumerator
RESTINIO_WEBSOCKET_OPCODES_GEN 
unknown_frame 
Examples:
sample/websocket_detailed/main.cpp.

Definition at line 36 of file message.hpp.

◆ status_code_t

enum restinio::websocket::basic::status_code_t : std::uint16_t
strong
Enumerator
normal_closure 
going_away 
protocol_error 
cant_accept_data 
no_status_provided 
connection_lost 
invalid_message_data 
policy_violation 
too_big_message 
more_extensions_expected 
unexpected_condition 

Definition at line 85 of file message.hpp.

Function Documentation

◆ activate()

void restinio::websocket::basic::activate ( ws_t ws)

Activate websocket: start receiving messages.

Definition at line 188 of file websocket.hpp.

◆ is_valid_opcode()

bool restinio::websocket::basic::is_valid_opcode ( opcode_t  opcode)
inline

Definition at line 64 of file message.hpp.

◆ opcode_to_string()

const char* restinio::websocket::basic::opcode_to_string ( opcode_t  opcode)
inline

Helper sunction to get method string name.

Definition at line 46 of file message.hpp.

◆ status_code_from_bin()

status_code_t restinio::websocket::basic::status_code_from_bin ( std::string  data)
inline

Definition at line 112 of file message.hpp.

◆ status_code_to_bin()

std::string restinio::websocket::basic::status_code_to_bin ( status_code_t  code)
inline

Definition at line 101 of file message.hpp.

◆ upgrade() [1/4]

template<typename Traits , typename WS_Message_Handler >
ws_handle_t restinio::websocket::basic::upgrade ( request_t req,
activation_t  activation_flag,
http_header_fields_t  upgrade_response_header_fields,
WS_Message_Handler  ws_message_handler 
)

Upgrade http-connection of a current request to a websocket connection.

Check if mandatory field is available.

Parameters
reqUpgrade request.
activation_flagActivation policy.
upgrade_response_header_fieldsResponse header fields.
ws_message_handlerMessage handler.

Definition at line 215 of file websocket.hpp.

◆ upgrade() [2/4]

template<typename Traits , typename WS_Message_Handler >
auto restinio::websocket::basic::upgrade ( request_t req,
activation_t  activation_flag,
std::string  sec_websocket_accept_field_value,
WS_Message_Handler  ws_message_handler 
)

Definition at line 293 of file websocket.hpp.

◆ upgrade() [3/4]

template<typename Traits , typename WS_Message_Handler >
auto restinio::websocket::basic::upgrade ( request_t req,
activation_t  activation_flag,
std::string  sec_websocket_accept_field_value,
std::string  sec_websocket_protocol_field_value,
WS_Message_Handler  ws_message_handler 
)

Definition at line 316 of file websocket.hpp.

◆ upgrade() [4/4]

template<typename Traits , typename WS_Message_Handler >
auto restinio::websocket::basic::upgrade ( request_t req,
activation_t  activation_flag,
WS_Message_Handler  ws_message_handler 
)

Definition at line 344 of file websocket.hpp.