WebSocket++  0.8.3-dev
C++ websocket client/server library
Namespaces | Classes | Functions
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

◆ extract_code()

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 294 of file close.hpp.

◆ extract_reason()

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 333 of file close.hpp.