Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
websocketpp Namespace Reference

Namespace for the WebSocket++ project.

Namespaces

namespace  close
 A package of types and methods for manipulating WebSocket close codes.
 
namespace  concurrency
 Concurrency handling support.
 
namespace  config
 
namespace  error
 Library level error codes.
 
namespace  extensions
 
namespace  frame
 Data structures and utility functions for manipulating WebSocket frames.
 
namespace  http
 HTTP handling support.
 
namespace  lib
 
namespace  log
 
namespace  md5
 Provides MD5 hashing functionality.
 
namespace  message_buffer
 
namespace  processor
 Processors encapsulate the protocol rules specific to each WebSocket version.
 
namespace  random
 Random number generation policies.
 
namespace  session
 
namespace  sha1
 
namespace  transport
 Transport policies provide network connectivity and timers.
 
namespace  utf8_validator
 
namespace  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.
 
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
 
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

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.
 

Typedef Documentation

◆ close_handler

typedef lib::function<void(connection_hdl)> websocketpp::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

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

Definition at line 41 of file error.hpp.

◆ fail_handler

typedef lib::function<void(connection_hdl)> websocketpp::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 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 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 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 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 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 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

Definition at line 351 of file uri.hpp.

◆ validate_handler

typedef lib::function<bool(connection_hdl)> websocketpp::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
Parameters
inputThe base64 encoded input data
Returns
A string representing the decoded raw bytes

Definition at line 131 of file base64.hpp.

131 {
132 size_t in_len = input.size();
133 int i = 0;
134 int j = 0;
135 int in_ = 0;
136 unsigned char char_array_4[4], char_array_3[3];
137 std::string ret;
138
139 while (in_len-- && ( input[in_] != '=') && is_base64(input[in_])) {
140 char_array_4[i++] = input[in_]; in_++;
141 if (i ==4) {
142 for (i = 0; i <4; i++) {
143 char_array_4[i] = static_cast<unsigned char>(base64_chars.find(char_array_4[i]));
144 }
145
146 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
147 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
148 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
149
150 for (i = 0; (i < 3); i++) {
151 ret += char_array_3[i];
152 }
153 i = 0;
154 }
155 }
156
157 if (i) {
158 for (j = i; j <4; j++)
159 char_array_4[j] = 0;
160
161 for (j = 0; j <4; j++)
162 char_array_4[j] = static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
163
164 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
165 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
166 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
167
168 for (j = 0; (j < i - 1); j++) {
169 ret += static_cast<std::string::value_type>(char_array_3[j]);
170 }
171 }
172
173 return ret;
174}
CK_RV ret
uint16_t j
size_t in_len

◆ base64_encode() [1/2]

std::string websocketpp::base64_encode ( std::string const & input)
inline
Parameters
inputThe input data
Returns
A base64 encoded string representing input

Definition at line 119 of file base64.hpp.

119 {
120 return base64_encode(
121 reinterpret_cast<const unsigned char *>(input.data()),
122 input.size()
123 );
124}
Here is the call graph for this function:

◆ base64_encode() [2/2]

std::string websocketpp::base64_encode ( unsigned char const * input,
size_t len )
inline
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.

66 {
67 std::string ret;
68 int i = 0;
69 int j = 0;
70 unsigned char char_array_3[3];
71 unsigned char char_array_4[4];
72
73 while (len--) {
74 char_array_3[i++] = *(input++);
75 if (i == 3) {
76 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
77 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) +
78 ((char_array_3[1] & 0xf0) >> 4);
79 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) +
80 ((char_array_3[2] & 0xc0) >> 6);
81 char_array_4[3] = char_array_3[2] & 0x3f;
82
83 for(i = 0; (i <4) ; i++) {
84 ret += base64_chars[char_array_4[i]];
85 }
86 i = 0;
87 }
88 }
89
90 if (i) {
91 for(j = i; j < 3; j++) {
92 char_array_3[j] = '\0';
93 }
94
95 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
96 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) +
97 ((char_array_3[1] & 0xf0) >> 4);
98 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) +
99 ((char_array_3[2] & 0xc0) >> 6);
100 char_array_4[3] = char_array_3[2] & 0x3f;
101
102 for (j = 0; (j < i + 1); j++) {
103 ret += base64_chars[char_array_4[j]];
104 }
105
106 while((i++ < 3)) {
107 ret += '=';
108 }
109 }
110
111 return ret;
112}
size_t len
Here is the caller graph for this function: