NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
websocketpp::close Namespace Reference

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...
 

Detailed Description

A package of types and methods for manipulating WebSocket close codes.

Function Documentation

status::value websocketpp::close::extract_code ( std::string const &  payload,
lib::error_code &  ec 
)
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.

Parameters
[in]payloadClose frame payload value received over the wire.
[out]ecSet to indicate what error occurred, if any.
Returns
The extracted value

Definition at line 283 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< config >::get_supported_versions().

std::string websocketpp::close::extract_reason ( std::string const &  payload,
lib::error_code &  ec 
)
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.

Parameters
[in]payloadThe payload string to extract a reason from.
[out]ecSet to indicate what error occurred, if any.
Returns
The reason string.

Definition at line 322 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< config >::get_supported_versions().