Go to the documentation of this file.
24 #define RESTINIO_WEBSOCKET_OPCODES_MAP( RESTINIO_GEN ) \
25 RESTINIO_GEN( continuation_frame, 0x00 ) \
26 RESTINIO_GEN( text_frame, 0x01 ) \
27 RESTINIO_GEN( binary_frame, 0x02 ) \
28 RESTINIO_GEN( connection_close_frame, 0x08 ) \
29 RESTINIO_GEN( ping_frame, 0x09 ) \
30 RESTINIO_GEN( pong_frame, 0x0A )
38 #define RESTINIO_WEBSOCKET_OPCODES_GEN( name, code ) name = code,
40 #undef RESTINIO_WEBSOCKET_OPCODES_GEN
48 const char * result =
"unknown_frame";
51 #define RESTINIO_WEBSOCKET_OPCODES_GEN( name, code ) \
52 case opcode_t::name: result = #name; break;
55 #undef RESTINIO_WEBSOCKET_OPCODES_GEN
69 #define RESTINIO_WEBSOCKET_OPCODES_GEN( name, code ) \
70 case opcode_t::name: break;
73 #undef RESTINIO_WEBSOCKET_OPCODES_GEN
75 default: result =
false;
87 normal_closure = 1000,
89 protocol_error = 1002,
90 cant_accept_data = 1003,
91 no_status_provided = 1005,
92 connection_lost = 1006,
93 invalid_message_data = 1007,
94 policy_violation = 1008,
95 too_big_message = 1009,
96 more_extensions_expected = 1010,
106 n_bits_from<char, 8>(
static_cast<std::uint16_t
>(
code) ),
107 n_bits_from<char, 0>(
static_cast<std::uint16_t
>(
code) )
116 std::uint16_t result{ 0 };
117 if( 2 <= data.size() )
119 result |=
static_cast< std::uint8_t
>( data[ 0 ] );
121 result |=
static_cast< std::uint8_t
>( data[ 1 ] );
144 :
public std::enable_shared_from_this< message_t >
void set_payload(std::string str)
std::shared_ptr< message_t > message_handle_t
Request handler, that is the type for calling request handlers.
const char * opcode_to_string(opcode_t opcode)
Helper sunction to get method string name.
constexpr final_frame_flag_t not_final_frame
final_frame_flag_t final_flag() const noexcept
Get final flag.
nonstd::string_view string_view_t
std::string m_payload
Websocket message payload.
bool is_valid_opcode(opcode_t opcode)
std::string & payload() noexcept
std::function< void(message_handle_t) > default_message_handler_t
final_frame_flag_t m_final_flag
Final flag.
message_t(final_frame_flag_t final_flag, opcode_t opcode, std::string payload)
constexpr final_frame_flag_t final_frame
#define RESTINIO_WEBSOCKET_OPCODES_GEN(name, code)
#define RESTINIO_WEBSOCKET_OPCODES_MAP(RESTINIO_GEN)
message_t(final_frame_flag_t final_flag, opcode_t opcode)
bool is_final() const noexcept
const std::string & payload() const noexcept
void set_final_flag(final_frame_flag_t final_flag) noexcept
void set_opcode(opcode_t opcode) noexcept
status_code_t status_code_from_bin(string_view_t data)
final_frame_flag_t
WS frame (message) "final"/"not final" flag.
std::string status_code_to_bin(status_code_t code)
RESTINIO_WEBSOCKET_OPCODES_GEN(name, code)
opcode_t opcode() const noexcept