A package of types and methods for manipulating WebSocket close codes. More...
Namespaces | |
status | |
A package of types and methods for manipulating WebSocket close status'. | |
Classes | |
union | code_converter |
Type used to convert close statuses between integer and wire representations. More... | |
Functions | |
status::value | extract_code (std::string const &payload, lib::error_code &ec) |
Extract a close code value from a close payload. More... | |
std::string | extract_reason (std::string const &payload, lib::error_code &ec) |
Extract the reason string from a close payload. More... | |
A package of types and methods for manipulating WebSocket close codes.
|
inline |
Extract a close code value from a close payload.
If there is no close value (ie string is empty) status::no_status is returned. If a code couldn't be extracted (usually do to a short or otherwise mangled payload) status::protocol_error is returned and the ec value is flagged as an error. Note that this case is different than the case where protocol error is received over the wire.
If the value is in an invalid or reserved range ec is set accordingly.
[in] | payload | Close frame payload value received over the wire. |
[out] | ec | Set to indicate what error occurred, if any. |
Definition at line 294 of file close.hpp.
References websocketpp::error::bad_close_code, websocketpp::close::code_converter::c, websocketpp::close::code_converter::i, websocketpp::close::status::invalid(), websocketpp::error::invalid_close_code, websocketpp::error::make_error_code(), websocketpp::close::status::no_status, websocketpp::close::status::protocol_error, websocketpp::close::status::reserved(), and websocketpp::error::reserved_close_code.
Referenced by BOOST_AUTO_TEST_CASE(), and websocketpp::connection< stub_config >::get_supported_versions().
|
inline |
Extract the reason string from a close payload.
The string should be a valid UTF8 message. error::invalid_utf8 will be set if the function extracts a reason that is not valid UTF8.
[in] | payload | The payload string to extract a reason from. |
[out] | ec | Set to indicate what error occurred, if any. |
Definition at line 333 of file close.hpp.
References websocketpp::error::invalid_utf8, websocketpp::error::make_error_code(), and websocketpp::utf8_validator::validate().
Referenced by BOOST_AUTO_TEST_CASE(), and websocketpp::connection< stub_config >::get_supported_versions().