NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
websocketpp::processor::hybi00< config > Class Template Reference

Processor for Hybi Draft version 00. More...

#include <hybi00.hpp>

Inheritance diagram for websocketpp::processor::hybi00< config >:
Collaboration diagram for websocketpp::processor::hybi00< config >:

Public Types

typedef processor< configbase
 
typedef config::request_type request_type
 
typedef config::response_type response_type
 
typedef config::message_type message_type
 
typedef message_type::ptr message_ptr
 
typedef config::con_msg_manager_type::ptr msg_manager_ptr
 
- Public Types inherited from websocketpp::processor::processor< config >
typedef processor< configtype
 
typedef config::request_type request_type
 
typedef config::response_type response_type
 
typedef config::message_type::ptr message_ptr
 
typedef std::pair< lib::error_code, std::string > err_str_pair
 

Public Member Functions

 hybi00 (bool secure, bool p_is_server, msg_manager_ptr manager)
 
int get_version () const
 Get the protocol version of this processor. More...
 
lib::error_code validate_handshake (request_type const &r) const
 validate a WebSocket handshake request for this version More...
 
lib::error_code process_handshake (request_type const &req, std::string const &subprotocol, response_type &res) const
 Calculate the appropriate response for this websocket request. More...
 
lib::error_code client_handshake_request (request_type &, uri_ptr, std::vector< std::string > const &) const
 Fill in a set of request headers for a client connection request. More...
 
lib::error_code validate_server_handshake_response (request_type const &, response_type &) const
 Validate the server's response to an outgoing handshake request. More...
 
std::string get_raw (response_type const &res) const
 Given a completed response, get the raw bytes to put on the wire. More...
 
std::string const & get_origin (request_type const &r) const
 Return the value of the header containing the CORS origin. More...
 
lib::error_code extract_subprotocols (request_type const &req, std::vector< std::string > &subprotocol_list)
 Extracts requested subprotocols from a handshake request. More...
 
uri_ptr get_uri (request_type const &request) const
 Extracts client uri from a handshake request. More...
 
std::string get_key3 () const
 Get hybi00 handshake key3. More...
 
size_t consume (uint8_t *buf, size_t len, lib::error_code &ec)
 Process new websocket connection bytes. More...
 
bool ready () const
 Checks if there is a message ready. More...
 
bool get_error () const
 Tests whether the processor is in a fatal error state. More...
 
message_ptr get_message ()
 Retrieves the most recently processed message. More...
 
virtual lib::error_code prepare_data_frame (message_ptr in, message_ptr out)
 Prepare a message for writing. More...
 
lib::error_code prepare_ping (std::string const &, message_ptr) const
 Prepare a ping frame. More...
 
lib::error_code prepare_pong (std::string const &, message_ptr) const
 Prepare a pong frame. More...
 
lib::error_code prepare_close (close::status::value, std::string const &, message_ptr out) const
 Prepare a close frame. More...
 
- Public Member Functions inherited from websocketpp::processor::processor< config >
 processor (bool secure, bool p_is_server)
 
virtual ~processor ()
 
size_t get_max_message_size () const
 Get maximum message size. More...
 
void set_max_message_size (size_t new_value)
 Set maximum message size. More...
 
virtual bool has_permessage_compress () const
 Returns whether or not the permessage_compress extension is implemented. More...
 
virtual err_str_pair negotiate_extensions (request_type const &)
 Initializes extensions based on the Sec-WebSocket-Extensions header. More...
 
virtual err_str_pair negotiate_extensions (response_type const &)
 Initializes extensions based on the Sec-WebSocket-Extensions header. More...
 
virtual size_t get_bytes_needed () const
 Retrieves the number of bytes presently needed by the processor This value may be used as a hint to the transport layer as to how many bytes to wait for before running consume again. More...
 

Additional Inherited Members

- Protected Attributes inherited from websocketpp::processor::processor< config >
bool const m_secure
 
bool const m_server
 
size_t m_max_message_size
 

Detailed Description

template<typename config>
class websocketpp::processor::hybi00< config >

Processor for Hybi Draft version 00.

There are many differences between Hybi 00 and Hybi 13

Definition at line 54 of file hybi00.hpp.

Member Typedef Documentation

◆ base

template<typename config>
typedef processor<config> websocketpp::processor::hybi00< config >::base

Definition at line 56 of file hybi00.hpp.

◆ request_type

Definition at line 58 of file hybi00.hpp.

◆ response_type

Definition at line 59 of file hybi00.hpp.

◆ message_type

Definition at line 61 of file hybi00.hpp.

◆ message_ptr

template<typename config>
typedef message_type::ptr websocketpp::processor::hybi00< config >::message_ptr

Definition at line 62 of file hybi00.hpp.

◆ msg_manager_ptr

Definition at line 64 of file hybi00.hpp.

Constructor & Destructor Documentation

◆ hybi00()

template<typename config>
websocketpp::processor::hybi00< config >::hybi00 ( bool  secure,
bool  p_is_server,
msg_manager_ptr  manager 
)
inlineexplicit

Definition at line 66 of file hybi00.hpp.

Member Function Documentation

◆ get_version()

template<typename config>
int websocketpp::processor::hybi00< config >::get_version ( ) const
inlinevirtual

Get the protocol version of this processor.

Implements websocketpp::processor::processor< config >.

Definition at line 73 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ validate_handshake()

template<typename config>
lib::error_code websocketpp::processor::hybi00< config >::validate_handshake ( request_type const &  request) const
inlinevirtual

validate a WebSocket handshake request for this version

Parameters
requestThe WebSocket handshake request to validate. is_websocket_handshake(request) must be true and get_websocket_version(request) must equal this->get_version().
Returns
A status code, 0 on success, non-zero for specific sorts of failure

Implements websocketpp::processor::processor< config >.

Definition at line 77 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ process_handshake()

template<typename config>
lib::error_code websocketpp::processor::hybi00< config >::process_handshake ( request_type const &  req,
std::string const &  subprotocol,
response_type res 
) const
inlinevirtual

Calculate the appropriate response for this websocket request.

Parameters
reqThe request to process
subprotocolThe subprotocol in use
resThe response to store the processed response in
Returns
An error code, 0 on success, non-zero for other errors

Implements websocketpp::processor::processor< config >.

Definition at line 100 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ client_handshake_request()

template<typename config>
lib::error_code websocketpp::processor::hybi00< config >::client_handshake_request ( request_type ,
uri_ptr  ,
std::vector< std::string > const &   
) const
inlinevirtual

Fill in a set of request headers for a client connection request.

The Hybi 00 processor only implements incoming connections so this will always return an error.

Parameters
[out]reqSet of headers to fill in
[in]uriThe uri being connected to
[in]subprotocolsThe list of subprotocols to request

Implements websocketpp::processor::processor< config >.

Definition at line 158 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ validate_server_handshake_response()

template<typename config>
lib::error_code websocketpp::processor::hybi00< config >::validate_server_handshake_response ( request_type const &  ,
response_type  
) const
inlinevirtual

Validate the server's response to an outgoing handshake request.

The Hybi 00 processor only implements incoming connections so this will always return an error.

Parameters
reqThe original request sent
resThe reponse to generate
Returns
An error code, 0 on success, non-zero for other errors

Implements websocketpp::processor::processor< config >.

Definition at line 173 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ get_raw()

template<typename config>
std::string websocketpp::processor::hybi00< config >::get_raw ( response_type const &  request) const
inlinevirtual

Given a completed response, get the raw bytes to put on the wire.

Implements websocketpp::processor::processor< config >.

Definition at line 179 of file hybi00.hpp.

◆ get_origin()

template<typename config>
std::string const& websocketpp::processor::hybi00< config >::get_origin ( request_type const &  request) const
inlinevirtual

Return the value of the header containing the CORS origin.

Implements websocketpp::processor::processor< config >.

Definition at line 185 of file hybi00.hpp.

◆ extract_subprotocols()

template<typename config>
lib::error_code websocketpp::processor::hybi00< config >::extract_subprotocols ( request_type const &  req,
std::vector< std::string > &  subprotocol_list 
)
inlinevirtual

Extracts requested subprotocols from a handshake request.

hybi00 does support subprotocols https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00#section-1.9

Parameters
[in]reqThe request to extract from
[out]subprotocol_listA reference to a vector of strings to store the results in.

Implements websocketpp::processor::processor< config >.

Definition at line 198 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ get_uri()

template<typename config>
uri_ptr websocketpp::processor::hybi00< config >::get_uri ( request_type const &  request) const
inlinevirtual

Extracts client uri from a handshake request.

Implements websocketpp::processor::processor< config >.

Definition at line 217 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), and websocketpp::processor::hybi00< stub_config >::process_handshake().

◆ get_key3()

template<typename config>
std::string websocketpp::processor::hybi00< config >::get_key3 ( ) const
inline

Get hybi00 handshake key3.

Todo:
This doesn't appear to be used anymore.

It might be able to be removed

Definition at line 247 of file hybi00.hpp.

◆ consume()

template<typename config>
size_t websocketpp::processor::hybi00< config >::consume ( uint8_t *  buf,
size_t  len,
lib::error_code &  ec 
)
inlinevirtual

Process new websocket connection bytes.

Implements websocketpp::processor::processor< config >.

Definition at line 252 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ ready()

template<typename config>
bool websocketpp::processor::hybi00< config >::ready ( ) const
inlinevirtual

Checks if there is a message ready.

Checks if the most recent consume operation processed enough bytes to complete a new WebSocket message. The message can be retrieved by calling get_message() which will reset the internal state to not-ready and allow consume to read more bytes.

Returns
Whether or not a message is ready.

Implements websocketpp::processor::processor< config >.

Definition at line 309 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ get_error()

template<typename config>
bool websocketpp::processor::hybi00< config >::get_error ( ) const
inlinevirtual

Tests whether the processor is in a fatal error state.

Implements websocketpp::processor::processor< config >.

Definition at line 313 of file hybi00.hpp.

◆ get_message()

template<typename config>
message_ptr websocketpp::processor::hybi00< config >::get_message ( )
inlinevirtual

Retrieves the most recently processed message.

Retrieves a shared pointer to the recently completed message if there is one. If ready() returns true then there is a message available. Retrieving the message with get_message will reset the state of ready. As such, each new message may be retrieved only once. Calling get_message when there is no message available will result in a null pointer being returned.

Returns
A pointer to the most recently processed message or a null shared pointer.

Implements websocketpp::processor::processor< config >.

Definition at line 317 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ prepare_data_frame()

template<typename config>
virtual lib::error_code websocketpp::processor::hybi00< config >::prepare_data_frame ( message_ptr  in,
message_ptr  out 
)
inlinevirtual

Prepare a message for writing.

Performs validation, masking, compression, etc. will return an error if there was an error, otherwise msg will be ready to be written

Implements websocketpp::processor::processor< config >.

Definition at line 329 of file hybi00.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ prepare_ping()

template<typename config>
lib::error_code websocketpp::processor::hybi00< config >::prepare_ping ( std::string const &  ,
message_ptr   
) const
inlinevirtual

Prepare a ping frame.

Hybi 00 doesn't support pings so this will always return an error

Parameters
inThe string to use for the ping payload
outThe message buffer to prepare the ping in.
Returns
Status code, zero on success, non-zero on failure

Implements websocketpp::processor::processor< config >.

Definition at line 373 of file hybi00.hpp.

◆ prepare_pong()

template<typename config>
lib::error_code websocketpp::processor::hybi00< config >::prepare_pong ( std::string const &  ,
message_ptr   
) const
inlinevirtual

Prepare a pong frame.

Hybi 00 doesn't support pongs so this will always return an error

Parameters
inThe string to use for the pong payload
outThe message buffer to prepare the pong in.
Returns
Status code, zero on success, non-zero on failure

Implements websocketpp::processor::processor< config >.

Definition at line 386 of file hybi00.hpp.

◆ prepare_close()

template<typename config>
lib::error_code websocketpp::processor::hybi00< config >::prepare_close ( close::status::value  ,
std::string const &  ,
message_ptr  out 
) const
inlinevirtual

Prepare a close frame.

Hybi 00 doesn't support the close code or reason so these parameters are ignored.

Parameters
codeThe close code to send
reasonThe reason string to send
outThe message buffer to prepare the fame in
Returns
Status code, zero on success, non-zero on failure

Implements websocketpp::processor::processor< config >.

Definition at line 401 of file hybi00.hpp.


The documentation for this class was generated from the following file: