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;
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 >
message_t(final_frame_flag_t final_flag, opcode_t opcode)
void set_payload(std::string str)
void set_opcode(opcode_t opcode) noexcept
final_frame_flag_t final_flag() const noexcept
Get final flag.
const std::string & payload() const noexcept
opcode_t opcode() const noexcept
void set_final_flag(final_frame_flag_t final_flag) noexcept
final_frame_flag_t m_final_flag
Final flag.
message_t(final_frame_flag_t final_flag, opcode_t opcode, std::string payload)
bool is_final() const noexcept
std::string m_payload
Websocket message payload.
std::string & payload() noexcept
#define RESTINIO_WEBSOCKET_OPCODES_GEN(name, code)
#define RESTINIO_WEBSOCKET_OPCODES_MAP(RESTINIO_GEN)
@ more_extensions_expected
std::shared_ptr< message_t > message_handle_t
Request handler, that is the type for calling request handlers.
std::function< void(message_handle_t) > default_message_handler_t
constexpr final_frame_flag_t final_frame
bool is_valid_opcode(opcode_t opcode)
constexpr final_frame_flag_t not_final_frame
const char * opcode_to_string(opcode_t opcode)
Helper sunction to get method string name.
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)
nonstd::string_view string_view_t