WebSocket++  0.8.3-dev
C++ websocket client/server library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Namespaces | Classes | Typedefs | Functions | Variables
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.
 
 error
 Library level error codes.
 
 extensions
 
 frame
 Data structures and utility functions for manipulating WebSocket frames.
 
 http
 HTTP handling support.
 
 md5
 Provides MD5 hashing functionality.
 
 processor
 Processors encapsulate the protocol rules specific to each WebSocket version.
 
 random
 Random number generation policies.
 
 transport
 Transport policies provide network connectivity and timers.
 
 uri_helper
 A group of helper methods for parsing and validating URIs against RFC 3986.
 
 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.
 
typedef lib::shared_ptr< uriuri_ptr
 Pointer to a URI.
 

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.
 
static uint16_t const uri_default_port = 80
 Default port for ws://.
 
static uint16_t const uri_default_secure_port = 443
 Default port for wss://.
 
static int const major_version = 0
 Library major version number.
 
static int const minor_version = 8
 Library minor version number.
 
static int const patch_version = 3
 Library patch version number.
 
static char const prerelease_flag [] = "dev"
 Library pre-release flag. More...
 
static char const user_agent [] = "WebSocket++/0.8.3-dev"
 Default user agent string.
 

Detailed Description

Namespace for the WebSocket++ project.

Typedef Documentation

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

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

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

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

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

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

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

Function Documentation

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

◆ base64_encode() [1/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.

◆ base64_encode() [2/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.

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

◆ 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

Variable Documentation

◆ base64_chars

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

Definition at line 43 of file base64.hpp.

◆ prerelease_flag

char const websocketpp::prerelease_flag[] = "dev"
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.