Loading...
Searching...
No Matches
websocketpp Namespace Reference

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

## Namespaces

namespace | transport
| Transport policies provide network connectivity and timers.
namespace | concurrency
| Concurrency handling support.
namespace | http
| HTTP handling support.
namespace | random
| Random number generation policies.
namespace | extensions
namespace | uri_helper
| A group of helper methods for parsing and validating URIs against RFC 3986.
namespace | error
| Library level error codes.
namespace | frame
| Data structures and utility functions for manipulating WebSocket frames.
namespace | utility
| Generic non-websocket specific utility functions and data structures.
namespace | close
| A package of types and methods for manipulating WebSocket close codes.
namespace | processor
| Processors encapsulate the protocol rules specific to each WebSocket version.
namespace | md5
| Provides MD5 hashing functionality.

## Classes

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

## Typedefs

typedef lib::shared_ptr< uri > | uri_ptr
| Pointer to a URI.
typedef std::pair< lib::error_code, std::string > | err_str_pair
| Combination error code / string type for returning two values.
typedef lib::weak_ptr< void > | connection_hdl
| A handle to uniquely identify a connection.
typedef lib::function< void(connection_hdl)> | open_handler
| The type and function signature of an open handler.
typedef lib::function< void(connection_hdl)> | close_handler
| The type and function signature of a close handler.
typedef lib::function< void(connection_hdl)> | fail_handler
| The type and function signature of a fail handler.
typedef lib::function< void(connection_hdl)> | interrupt_handler
| The type and function signature of an interrupt handler.
typedef lib::function< bool(connection_hdl, std::string)> | ping_handler
| The type and function signature of a ping handler.
typedef lib::function< void(connection_hdl, std::string)> | pong_handler
| The type and function signature of a pong handler.
typedef lib::function< void(connection_hdl, std::string)> | pong_timeout_handler
| The type and function signature of a pong timeout handler.
typedef lib::function< bool(connection_hdl)> | validate_handler
| The type and function signature of a validate handler.
typedef lib::function< void(connection_hdl)> | http_handler
| The type and function signature of a http handler.
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

## Functions

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

## Variables

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

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

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

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

## uri_ptr

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

Pointer to a URI.

Definition at line 791 of file uri.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.

## write_frame_handler

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

Definition at line 155 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

  input | The 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

  input | The 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

  input | The input data
  len | The length of input in bytes

Returns
  A base64 encoded string representing input

Definition at line 66 of file base64.hpp.

## is_base64()

bool websocketpp::is_base64 | ( | unsigned char | c | ) |

inline static

Test whether a character is a valid base64 character.

Parameters

  c | The character to test

Returns
  true if c is a valid base64 character

Definition at line 53 of file base64.hpp.

## versions_supported()

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.

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

## major_version

int const websocketpp::major_version = 0

static

Library major version number.

Definition at line 43 of file version.hpp.

## minor_version

int const websocketpp::minor_version = 8

static

Library minor version number.

Definition at line 45 of file version.hpp.

## patch_version

int const websocketpp::patch_version = 3

static

Library patch version number.

Definition at line 47 of file version.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.

## uri_default_port

uint16_t const websocketpp::uri_default_port = 80

static

Default port for ws://.

Definition at line 45 of file uri.hpp.

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

## user_agent

char const websocketpp::user_agent[] = "WebSocket++/0.8.3-dev"

static

Default user agent string.

Definition at line 57 of file version.hpp.