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

Namespace for the WebSocket++ project. More...

Namespaces

 close
 A package of types and methods for manipulating WebSocket close codes.
 
 concurrency
 Concurrency handling support.
 
 config
 
 error
 Library level error codes.
 
 extensions
 Some generic information about extensions.
 
 frame
 Data structures and utility functions for manipulating WebSocket frames.
 
 http
 HTTP handling support.
 
 lib
 
 log
 
 md5
 Provides MD5 hashing functionality.
 
 message_buffer
 
 processor
 Processors encapsulate the protocol rules specific to each WebSocket version.
 
 random
 Random number generation policies.
 
 session
 
 sha1
 
 transport
 Transport policies provide network connectivity and timers.
 
 utf8_validator
 
 utility
 Generic non-websocket specific utility functions and data structures.
 

Classes

class  client
 Client endpoint role based on the given config. More...
 
class  connection
 Represents an individual WebSocket connection. More...
 
class  connection_base
 Stub for user supplied base class. More...
 
class  endpoint
 Creates and manages connections associated with a WebSocket endpoint. More...
 
class  endpoint_base
 Stub for user supplied base class. More...
 
class  exception
 
class  server
 Server endpoint role based on the given config. More...
 
class  uri
 

Typedefs

typedef lib::weak_ptr< void > connection_hdl
 A handle to uniquely identify a connection. More...
 
typedef lib::function< void(connection_hdl)> open_handler
 The type and function signature of an open handler. More...
 
typedef lib::function< void(connection_hdl)> close_handler
 The type and function signature of a close handler. More...
 
typedef lib::function< void(connection_hdl)> fail_handler
 The type and function signature of a fail handler. More...
 
typedef lib::function< void(connection_hdl)> interrupt_handler
 The type and function signature of an interrupt handler. More...
 
typedef lib::function< bool(connection_hdl, std::string)> ping_handler
 The type and function signature of a ping handler. More...
 
typedef lib::function< void(connection_hdl, std::string)> pong_handler
 The type and function signature of a pong handler. More...
 
typedef lib::function< void(connection_hdl, std::string)> pong_timeout_handler
 The type and function signature of a pong timeout handler. More...
 
typedef lib::function< bool(connection_hdl)> validate_handler
 The type and function signature of a validate handler. More...
 
typedef lib::function< void(connection_hdl)> http_handler
 The type and function signature of a http handler. More...
 
typedef lib::function< void(lib::error_code const &ec, size_t bytes_transferred)> read_handler
 
typedef lib::function< void(lib::error_code const &ec)> write_frame_handler
 
typedef std::pair< lib::error_code, std::string > err_str_pair
 Combination error code / string type for returning two values. More...
 
typedef lib::shared_ptr< uriuri_ptr
 Pointer to a URI. More...
 

Functions

static bool is_base64 (unsigned char c)
 Test whether a character is a valid base64 character. More...
 
std::string base64_encode (unsigned char const *input, size_t len)
 Encode a char buffer into a base64 string. More...
 
std::string base64_encode (std::string const &input)
 Encode a string into a base64 string. More...
 
std::string base64_decode (std::string const &input)
 Decode a base64 encoded string into a string of raw bytes. More...
 
static std::vector< int > const versions_supported (helper, helper+4)
 Container that stores the list of protocol versions supported. More...
 

Variables

static std::string const base64_chars
 
static int const helper [] = {0,7,8,13}
 Helper array to get around lack of initializer lists pre C++11. More...
 
static uint16_t const uri_default_port = 80
 Default port for ws://. More...
 
static uint16_t const uri_default_secure_port = 443
 Default port for wss://. More...
 
static int const major_version = 0
 Library major version number. More...
 
static int const minor_version = 8
 Library minor version number. More...
 
static int const patch_version = 1
 Library patch version number. More...
 
static char const prerelease_flag [] = ""
 Library pre-release flag. More...
 
static char const user_agent [] = "WebSocket++/0.8.1"
 Default user agent string. More...
 

Detailed Description

Namespace for the WebSocket++ project.

Typedef Documentation

◆ connection_hdl

typedef lib::weak_ptr<void> websocketpp::connection_hdl

A handle to uniquely identify a connection.

This type uniquely identifies a connection. It is implemented as a weak pointer to the connection in question. This provides uniqueness across multiple endpoints and ensures that IDs never conflict or run out.

It is safe to make copies of this handle, store those copies in containers, and use them from other threads.

This handle can be upgraded to a full shared_ptr using endpoint::get_con_from_hdl() from within a handler fired by the connection that owns the handler.

Definition at line 48 of file connection_hdl.hpp.

◆ open_handler

typedef lib::function<void(connection_hdl)> websocketpp::open_handler

The type and function signature of an open handler.

The open handler is called once for every successful WebSocket connection attempt. Either the fail handler or the open handler will be called for each WebSocket connection attempt. HTTP Connections that did not attempt to upgrade the connection to the WebSocket protocol will trigger the http handler instead of fail/open.

Definition at line 59 of file connection.hpp.

◆ close_handler

typedef lib::function<void(connection_hdl)> websocketpp::close_handler

The type and function signature of a close handler.

The close handler is called once for every successfully established connection after it is no longer capable of sending or receiving new messages

The close handler will be called exactly once for every connection for which the open handler was called.

Definition at line 69 of file connection.hpp.

◆ fail_handler

typedef lib::function<void(connection_hdl)> websocketpp::fail_handler

The type and function signature of a fail handler.

The fail handler is called once for every unsuccessful WebSocket connection attempt. Either the fail handler or the open handler will be called for each WebSocket connection attempt. HTTP Connections that did not attempt to upgrade the connection to the WebSocket protocol will trigger the http handler instead of fail/open.

Definition at line 79 of file connection.hpp.

◆ interrupt_handler

typedef lib::function<void(connection_hdl)> websocketpp::interrupt_handler

The type and function signature of an interrupt handler.

The interrupt handler is called when a connection receives an interrupt request from the application. Interrupts allow the application to trigger a handler to be run in the absense of a WebSocket level handler trigger (like a new message).

This is typically used by another application thread to schedule some tasks that can only be run from within the handler chain for thread safety reasons.

Definition at line 91 of file connection.hpp.

◆ ping_handler

typedef lib::function<bool(connection_hdl,std::string)> websocketpp::ping_handler

The type and function signature of a ping handler.

The ping handler is called when the connection receives a WebSocket ping control frame. The string argument contains the ping payload. The payload is a binary string up to 126 bytes in length. The ping handler returns a bool, true if a pong response should be sent, false if the pong response should be suppressed.

Definition at line 101 of file connection.hpp.

◆ pong_handler

typedef lib::function<void(connection_hdl,std::string)> websocketpp::pong_handler

The type and function signature of a pong handler.

The pong handler is called when the connection receives a WebSocket pong control frame. The string argument contains the pong payload. The payload is a binary string up to 126 bytes in length.

Definition at line 109 of file connection.hpp.

◆ pong_timeout_handler

typedef lib::function<void(connection_hdl,std::string)> websocketpp::pong_timeout_handler

The type and function signature of a pong timeout handler.

The pong timeout handler is called when a ping goes unanswered by a pong for longer than the locally specified timeout period.

Definition at line 116 of file connection.hpp.

◆ validate_handler

typedef lib::function<bool(connection_hdl)> websocketpp::validate_handler

The type and function signature of a validate handler.

The validate handler is called after a WebSocket handshake has been received and processed but before it has been accepted. This gives the application a chance to implement connection details specific policies for accepting connections and the ability to negotiate extensions and subprotocols.

The validate handler return value indicates whether or not the connection should be accepted. Additional methods may be called during the function to set response headers, set HTTP return/error codes, etc.

Definition at line 129 of file connection.hpp.

◆ http_handler

typedef lib::function<void(connection_hdl)> websocketpp::http_handler

The type and function signature of a http handler.

The http handler is called when an HTTP connection is made that does not attempt to upgrade the connection to the WebSocket protocol. This allows WebSocket++ servers to respond to these requests with regular HTTP responses.

This can be used to deliver error pages & dashboards and to deliver static files such as the base HTML & JavaScript for an otherwise single page WebSocket application.

Note: WebSocket++ is designed to be a high performance WebSocket server. It is not tuned to provide a full featured, high performance, HTTP web server solution. The HTTP handler is appropriate only for low volume HTTP traffic. If you expect to serve high volumes of HTTP traffic a dedicated HTTP web server is strongly recommended.

The default HTTP handler will return a 426 Upgrade Required error. Custom handlers may override the response status code to deliver any type of response.

Definition at line 151 of file connection.hpp.

◆ read_handler

typedef lib::function<void(lib::error_code const & ec, size_t bytes_transferred)> websocketpp::read_handler

Definition at line 154 of file connection.hpp.

◆ write_frame_handler

typedef lib::function<void(lib::error_code const & ec)> websocketpp::write_frame_handler

Definition at line 155 of file connection.hpp.

◆ err_str_pair

typedef std::pair<lib::error_code,std::string> websocketpp::err_str_pair

Combination error code / string type for returning two values.

Definition at line 41 of file error.hpp.

◆ uri_ptr

typedef lib::shared_ptr<uri> websocketpp::uri_ptr

Pointer to a URI.

Definition at line 352 of file uri.hpp.

Function Documentation

◆ is_base64()

static bool websocketpp::is_base64 ( unsigned char  c)
inlinestatic

Test whether a character is a valid base64 character.

Parameters
cThe character to test
Returns
true if c is a valid base64 character

Definition at line 53 of file base64.hpp.

Referenced by base64_decode().

◆ base64_encode() [1/2]

std::string websocketpp::base64_encode ( unsigned char const *  input,
size_t  len 
)
inline

Encode a char buffer into a base64 string.

Parameters
inputThe input data
lenThe length of input in bytes
Returns
A base64 encoded string representing input

Definition at line 66 of file base64.hpp.

Referenced by base64_encode(), websocketpp::processor::hybi13< stub_config >::client_handshake_request(), websocketpp::processor::hybi13< stub_config >::process_handshake_key(), and websocketpp::transport::asio::connection< config >::set_proxy_basic_auth().

◆ base64_encode() [2/2]

std::string websocketpp::base64_encode ( std::string const &  input)
inline

Encode a string into a base64 string.

Parameters
inputThe input data
Returns
A base64 encoded string representing input

Definition at line 119 of file base64.hpp.

References base64_encode().

◆ base64_decode()

std::string websocketpp::base64_decode ( std::string const &  input)
inline

Decode a base64 encoded string into a string of raw bytes.

Parameters
inputThe base64 encoded input data
Returns
A string representing the decoded raw bytes

Definition at line 131 of file base64.hpp.

References is_base64().

◆ versions_supported()

static std::vector<int> const websocketpp::versions_supported ( helper  ,
helper 4 
)
static

Container that stores the list of protocol versions supported.

Todo:
Move this to configs to allow compile/runtime disabling or enabling of protocol versions

Referenced by websocketpp::connection< stub_config >::get_supported_versions(), and websocketpp::connection< stub_config >::initialize_processor().

Variable Documentation

◆ base64_chars

std::string const websocketpp::base64_chars
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/"

Definition at line 43 of file base64.hpp.

◆ helper

int const websocketpp::helper[] = {0,7,8,13}
static

Helper array to get around lack of initializer lists pre C++11.

Definition at line 167 of file connection.hpp.

◆ uri_default_port

uint16_t const websocketpp::uri_default_port = 80
static

Default port for ws://.

Definition at line 45 of file uri.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ uri_default_secure_port

uint16_t const websocketpp::uri_default_secure_port = 443
static

Default port for wss://.

Definition at line 47 of file uri.hpp.

◆ major_version

int const websocketpp::major_version = 0
static

Library major version number.

Definition at line 43 of file version.hpp.

Referenced by main().

◆ minor_version

int const websocketpp::minor_version = 8
static

Library minor version number.

Definition at line 45 of file version.hpp.

Referenced by main().

◆ patch_version

int const websocketpp::patch_version = 1
static

Library patch version number.

Definition at line 47 of file version.hpp.

Referenced by main().

◆ prerelease_flag

char const websocketpp::prerelease_flag[] = ""
static

Library pre-release flag.

This is a textual flag indicating the type and number for pre-release versions (dev, alpha, beta, rc). This will be blank for release versions.

Definition at line 54 of file version.hpp.

◆ user_agent

char const websocketpp::user_agent[] = "WebSocket++/0.8.1"
static

Default user agent string.

Definition at line 57 of file version.hpp.

Referenced by BOOST_AUTO_TEST_CASE(), and main().