Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
connection.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014, Peter Thorson. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of the WebSocket++ Project nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27
28#ifndef WEBSOCKETPP_CONNECTION_HPP
29#define WEBSOCKETPP_CONNECTION_HPP
30
31#include <websocketpp/close.hpp>
32#include <websocketpp/error.hpp>
33#include <websocketpp/frame.hpp>
34
39
43
44#include <queue>
45#include <sstream>
46#include <string>
47#include <vector>
48
49namespace websocketpp {
50
52
59typedef lib::function<void(connection_hdl)> open_handler;
60
62
69typedef lib::function<void(connection_hdl)> close_handler;
70
72
79typedef lib::function<void(connection_hdl)> fail_handler;
80
82
91typedef lib::function<void(connection_hdl)> interrupt_handler;
92
94
101typedef lib::function<bool(connection_hdl,std::string)> ping_handler;
102
104
109typedef lib::function<void(connection_hdl,std::string)> pong_handler;
110
112
116typedef lib::function<void(connection_hdl,std::string)> pong_timeout_handler;
117
119
129typedef lib::function<bool(connection_hdl)> validate_handler;
130
132
151typedef lib::function<void(connection_hdl)> http_handler;
152
153//
154typedef lib::function<void(lib::error_code const & ec, size_t bytes_transferred)> read_handler;
155typedef lib::function<void(lib::error_code const & ec)> write_frame_handler;
156
157// constants related to the default WebSocket protocol versions available
158#ifdef _WEBSOCKETPP_INITIALIZER_LISTS_ // simplified C++11 version
160
164 static std::vector<int> const versions_supported = {0,7,8,13};
165#else
167 static int const helper[] = {0,7,8,13};
169
173 static std::vector<int> const versions_supported(helper,helper+4);
174#endif
175
176namespace session {
177namespace state {
178 // externally visible session state (states based on the RFC)
179 enum value {
181 open = 1,
183 closed = 3
184 };
185} // namespace state
186
187
188namespace fail {
189namespace status {
190 enum value {
191 GOOD = 0, // no failure yet!
192 SYSTEM = 1, // system call returned error, check that code
193 WEBSOCKET = 2, // websocket close codes contain error
194 UNKNOWN = 3, // No failure information is available
195 TIMEOUT_TLS = 4, // TLS handshake timed out
196 TIMEOUT_WS = 5 // WS handshake timed out
197 };
198} // namespace status
199} // namespace fail
200
201namespace internal_state {
202 // More granular internal states. These are used for multi-threaded
203 // connection synchronization and preventing values that are not yet or no
204 // longer available from being used.
205
216} // namespace internal_state
217
218
219namespace http_state {
220 // states to keep track of the progress of http connections
221
229} // namespace http_state
230
231} // namespace session
232
234template <typename config>
236 : public config::transport_type::transport_con_type
237 , public config::connection_base
238{
239public:
243 typedef lib::shared_ptr<type> ptr;
245 typedef lib::weak_ptr<type> weak_ptr;
246
248 typedef typename config::concurrency_type concurrency_type;
250 typedef typename config::alog_type alog_type;
252 typedef typename config::elog_type elog_type;
253
255 typedef typename config::transport_type::transport_con_type
258 typedef typename transport_con_type::ptr transport_con_ptr;
259
260 typedef lib::function<void(ptr)> termination_handler;
261
262 typedef typename concurrency_type::scoped_lock_type scoped_lock_type;
263 typedef typename concurrency_type::mutex_type mutex_type;
264
265 typedef typename config::request_type request_type;
266 typedef typename config::response_type response_type;
267
268 typedef typename config::message_type message_type;
269 typedef typename message_type::ptr message_ptr;
270
271 typedef typename config::con_msg_manager_type con_msg_manager_type;
272 typedef typename con_msg_manager_type::ptr con_msg_manager_ptr;
273
275 typedef typename config::rng_type rng_type;
276
278 typedef lib::shared_ptr<processor_type> processor_ptr;
279
280 // Message handler (needs to know message type)
281 typedef lib::function<void(connection_hdl,message_ptr)> message_handler;
282
284 typedef typename transport_con_type::timer_ptr timer_ptr;
285
286 // Misc Convenience Types
288
289private:
290 enum terminate_status {
291 failed = 1,
292 closed,
293 unknown
294 };
295public:
296
297 explicit connection(bool p_is_server, std::string const & ua, alog_type& alog,
298 elog_type& elog, rng_type & rng)
299 : transport_con_type(p_is_server, alog, elog)
300 , m_handle_read_frame(lib::bind(
302 this,
303 lib::placeholders::_1,
304 lib::placeholders::_2
305 ))
306 , m_write_frame_handler(lib::bind(
308 this,
309 lib::placeholders::_1
310 ))
311 , m_user_agent(ua)
312 , m_open_handshake_timeout_dur(config::timeout_open_handshake)
313 , m_close_handshake_timeout_dur(config::timeout_close_handshake)
314 , m_pong_timeout_dur(config::timeout_pong)
315 , m_max_message_size(config::max_message_size)
316 , m_state(session::state::connecting)
317 , m_internal_state(session::internal_state::USER_INIT)
318 , m_msg_manager(new con_msg_manager_type())
319 , m_send_buffer_size(0)
320 , m_write_flag(false)
321 , m_read_flag(true)
322 , m_is_server(p_is_server)
323 , m_alog(alog)
324 , m_elog(elog)
325 , m_rng(rng)
326 , m_local_close_code(close::status::abnormal_close)
327 , m_remote_close_code(close::status::abnormal_close)
328 , m_is_http(false)
329 , m_http_state(session::http_state::init)
330 , m_was_clean(false)
331 {
332 m_alog.write(log::alevel::devel,"connection constructor");
333 }
334
337 return lib::static_pointer_cast<type>(transport_con_type::get_shared());
338 }
339
341 // Set Handler Callbacks //
343
345
352 m_open_handler = h;
353 }
354
356
362 m_close_handler = h;
363 }
364
366
373 m_fail_handler = h;
374 }
375
377
388 m_ping_handler = h;
389 }
390
392
399 m_pong_handler = h;
400 }
401
403
422 m_pong_timeout_handler = h;
423 }
424
426
433 m_interrupt_handler = h;
434 }
435
437
448 m_http_handler = h;
449 }
450
452
464 m_validate_handler = h;
465 }
466
468
474 m_message_handler = h;
475 }
476
478 // Connection timeouts and other limits //
480
482
502 m_open_handshake_timeout_dur = dur;
503 }
504
506
526 m_close_handshake_timeout_dur = dur;
527 }
528
530
546 void set_pong_timeout(long dur) {
547 m_pong_timeout_dur = dur;
548 }
549
551
559 size_t get_max_message_size() const {
560 return m_max_message_size;
561 }
562
564
575 void set_max_message_size(size_t new_value) {
576 m_max_message_size = new_value;
577 if (m_processor) {
578 m_processor->set_max_message_size(new_value);
579 }
580 }
581
583
594 size_t get_max_http_body_size() const {
595 return m_request.get_max_body_size();
596 }
597
599
610 void set_max_http_body_size(size_t new_value) {
611 m_request.set_max_body_size(new_value);
612 }
613
615 // Uncategorized public methods //
617
619
629 size_t get_buffered_amount() const;
630
632
635 size_t buffered_amount() const {
636 return get_buffered_amount();
637 }
638
640 // Action Methods //
642
644
655 lib::error_code send(std::string const & payload, frame::opcode::value op =
657
659
672 lib::error_code send(void const * payload, size_t len, frame::opcode::value
674
676
688 lib::error_code send(message_ptr msg);
689
691
703 lib::error_code interrupt();
704
706 void handle_interrupt();
707
709
728 lib::error_code pause_reading();
729
732
734
740 lib::error_code resume_reading();
741
744
746
757 void ping(std::string const & payload);
758
760 void ping(std::string const & payload, lib::error_code & ec);
761
763 void handle_pong_timeout(std::string payload, lib::error_code const & ec);
764
766
775 void pong(std::string const & payload);
776
778 void pong(std::string const & payload, lib::error_code & ec);
779
781
800 void close(close::status::value const code, std::string const & reason);
801
803 void close(close::status::value const code, std::string const & reason,
804 lib::error_code & ec);
805
807 // Pass-through access to the uri information //
809
811
817 bool get_secure() const;
818
820
826 std::string const & get_host() const;
827
829
835 std::string const & get_resource() const;
836
838
844 uint16_t get_port() const;
845
847
853 uri_ptr get_uri() const;
854
856
862 void set_uri(uri_ptr uri);
863
865 // Subprotocol negotiation //
867
869
875 std::string const & get_subprotocol() const;
876
878
884 std::vector<std::string> const & get_requested_subprotocols() const;
885
887
899 void add_subprotocol(std::string const & request, lib::error_code & ec);
900
902
912 void add_subprotocol(std::string const & request);
913
915
927 void select_subprotocol(std::string const & value, lib::error_code & ec);
928
930
940 void select_subprotocol(std::string const & value);
941
943 // Pass-through access to the request and response objects //
945
947
953 std::string const & get_request_header(std::string const & key) const;
954
956
964 std::string const & get_request_body() const;
965
967
973 std::string const & get_response_header(std::string const & key) const;
974
976
984 return m_response.get_status_code();
985 }
986
988
995 std::string const & get_response_msg() const {
996 return m_response.get_status_msg();
997 }
998
1000
1014
1016
1028 void set_status(http::status_code::value code, std::string const & msg);
1029
1031
1043 void set_body(std::string const & value);
1044 void set_body(std::string && value);
1045
1047
1060 void append_header(std::string const & key, std::string const & val);
1061
1063
1075 void replace_header(std::string const & key, std::string const & val);
1076
1078
1087 void remove_header(std::string const & key);
1088
1090
1103 request_type const & get_request() const {
1104 return m_request;
1105 }
1106
1108
1122 response_type const & get_response() const {
1123 return m_response;
1124 }
1125
1127
1139 lib::error_code defer_http_response();
1140
1142
1151 void send_http_response(lib::error_code & ec);
1152
1154 void send_http_response();
1155
1156 // TODO HTTPNBIO: write_headers
1157 // function that processes headers + status so far and writes it to the wire
1158 // beginning the HTTP response body state. This method will ignore anything
1159 // in the response body.
1160
1161 // TODO HTTPNBIO: write_body_message
1162 // queues the specified message_buffer for async writing
1163
1164 // TODO HTTPNBIO: finish connection
1165 //
1166
1167 // TODO HTTPNBIO: write_response
1168 // Writes the whole response, headers + body and closes the connection
1169
1170
1171
1173 // Pass-through access to the other connection information //
1175
1177
1185 return m_connection_hdl;
1186 }
1187
1189
1192 bool is_server() const {
1193 return m_is_server;
1194 }
1195
1197
1203 std::string const & get_origin() const;
1204
1206
1212
1213
1215
1219 return m_local_close_code;
1220 }
1221
1223
1226 std::string const & get_local_close_reason() const {
1227 return m_local_close_reason;
1228 }
1229
1231
1235 return m_remote_close_code;
1236 }
1237
1239
1242 std::string const & get_remote_close_reason() const {
1243 return m_remote_close_reason;
1244 }
1245
1247
1255 lib::error_code get_ec() const {
1256 return m_ec;
1257 }
1258
1260
1279 const
1280 {
1281 return m_msg_manager->get_message(op, size);
1282 }
1283
1285 // The remaining public member functions are for internal/policy use //
1286 // only. Do not call from application code unless you understand what //
1287 // you are doing. //
1289
1290
1291
1292 void read_handshake(size_t num_bytes);
1293
1294 void handle_read_handshake(lib::error_code const & ec,
1295 size_t bytes_transferred);
1296 void handle_read_http_response(lib::error_code const & ec,
1297 size_t bytes_transferred);
1298
1299
1300 void handle_write_http_response(lib::error_code const & ec);
1301 void handle_send_http_request(lib::error_code const & ec);
1302
1303 void handle_open_handshake_timeout(lib::error_code const & ec);
1304 void handle_close_handshake_timeout(lib::error_code const & ec);
1305
1306 void handle_read_frame(lib::error_code const & ec, size_t bytes_transferred);
1307 void read_frame();
1308
1310 std::vector<int> const & get_supported_versions() const;
1311
1315
1316 void terminate(lib::error_code const & ec);
1317 void handle_terminate(terminate_status tstat, lib::error_code const & ec);
1318
1320
1325 void write_frame();
1326
1328
1339 void handle_write_frame(lib::error_code const & ec);
1340// protected:
1341 // This set of methods would really like to be protected, but doing so
1342 // requires that the endpoint be able to friend the connection. This is
1343 // allowed with C++11, but not prior versions
1344
1346 void start();
1347
1349
1358 m_connection_hdl = hdl;
1359 transport_con_type::set_handle(hdl);
1360 }
1361protected:
1362 void handle_transport_init(lib::error_code const & ec);
1363
1366 lib::error_code initialize_processor();
1367
1370 lib::error_code process_handshake_request();
1371private:
1372
1373
1375 void write_http_response(lib::error_code const & ec);
1376
1378 void send_http_request();
1379
1381 void write_http_response_error(lib::error_code const & ec);
1382
1384
1387 void process_control_frame(message_ptr msg);
1388
1390
1400 lib::error_code send_close_ack(close::status::value code =
1401 close::status::blank, std::string const & reason = std::string());
1402
1404
1418 lib::error_code send_close_frame(close::status::value code =
1419 close::status::blank, std::string const & reason = std::string(), bool ack = false,
1420 bool terminal = false);
1421
1423
1432 processor_ptr get_processor(int version) const;
1433
1435
1444 void write_push(message_ptr msg);
1445
1447
1457 message_ptr write_pop();
1458
1460
1465 void log_open_result();
1466
1468
1471 void log_close_result();
1472
1474
1477 void log_fail_result();
1478
1480
1483 void log_http_result();
1484
1486 template <typename error_type>
1487 void log_err(log::level l, char const * msg, error_type const & ec) {
1488 std::stringstream s;
1489 s << msg << " error: " << ec << " (" << ec.message() << ")";
1490 m_elog.write(l, s.str());
1491 }
1492
1493 // internal handler functions
1494 read_handler m_handle_read_frame;
1495 write_frame_handler m_write_frame_handler;
1496
1497 // static settings
1498 std::string const m_user_agent;
1499
1501 connection_hdl m_connection_hdl;
1502
1504 open_handler m_open_handler;
1505 close_handler m_close_handler;
1506 fail_handler m_fail_handler;
1507 ping_handler m_ping_handler;
1508 pong_handler m_pong_handler;
1509 pong_timeout_handler m_pong_timeout_handler;
1510 interrupt_handler m_interrupt_handler;
1511 http_handler m_http_handler;
1512 validate_handler m_validate_handler;
1513 message_handler m_message_handler;
1514
1516 long m_open_handshake_timeout_dur;
1517 long m_close_handshake_timeout_dur;
1518 long m_pong_timeout_dur;
1519 size_t m_max_message_size;
1520
1522
1525 session::state::value m_state;
1526
1528
1531 istate_type m_internal_state;
1532
1533 mutable mutex_type m_connection_state_lock;
1534
1536
1540 mutex_type m_write_lock;
1541
1542 // connection resources
1543 char m_buf[config::connection_read_buffer_size];
1544 size_t m_buf_cursor;
1545 termination_handler m_termination_handler;
1546 con_msg_manager_ptr m_msg_manager;
1547 timer_ptr m_handshake_timer;
1548 timer_ptr m_ping_timer;
1549
1552 std::string m_handshake_buffer;
1553
1555
1563 processor_ptr m_processor;
1564
1566
1569 std::queue<message_ptr> m_send_queue;
1570
1572
1575 size_t m_send_buffer_size;
1576
1578
1581 std::vector<transport::buffer> m_send_buffer;
1582
1585 std::vector<message_ptr> m_current_msgs;
1586
1588
1591 bool m_write_flag;
1592
1594 bool m_read_flag;
1595
1596 // connection data
1597 request_type m_request;
1598 response_type m_response;
1599 uri_ptr m_uri;
1600 std::string m_subprotocol;
1601
1602 // connection data that might not be necessary to keep around for the life
1603 // of the whole connection.
1604 std::vector<std::string> m_requested_subprotocols;
1605
1606 bool const m_is_server;
1607 alog_type& m_alog;
1608 elog_type& m_elog;
1609
1610 rng_type & m_rng;
1611
1612 // Close state
1614 close::status::value m_local_close_code;
1615
1617 std::string m_local_close_reason;
1618
1620 close::status::value m_remote_close_code;
1621
1623 std::string m_remote_close_reason;
1624
1626 lib::error_code m_ec;
1627
1630 bool m_is_http;
1631
1634 session::http_state::value m_http_state;
1635
1636 bool m_was_clean;
1637
1639 bool m_closed_by_me;
1640
1642 bool m_failed_by_me;
1643
1645 bool m_dropped_by_me;
1646};
1647
1648} // namespace websocketpp
1649
1651
1652#endif // WEBSOCKETPP_CONNECTION_HPP
Represents an individual WebSocket connection.
ptr get_shared()
Get a shared pointer to this component.
config::concurrency_type concurrency_type
Type of the concurrency component of this connection.
void handle_interrupt()
Transport inturrupt callback.
lib::function< void(ptr)> termination_handler
void set_message_handler(message_handler h)
Set message handler.
config::elog_type elog_type
Type of the error logging policy.
void handle_close_handshake_timeout(lib::error_code const &ec)
lib::error_code interrupt()
Asyncronously invoke handler::on_inturrupt.
void start()
Start the connection state machine.
std::string const & get_request_body() const
Retrieve a request body.
void ping(std::string const &payload)
Send a ping.
void set_close_handler(close_handler h)
Set close handler.
void handle_read_http_response(lib::error_code const &ec, size_t bytes_transferred)
void set_pong_handler(pong_handler h)
Set pong handler.
lib::error_code send(message_ptr msg)
Add a message to the outgoing send queue.
config::message_type message_type
config::response_type response_type
http::status_code::value get_response_code() const
Get response HTTP status code.
lib::error_code defer_http_response()
Defer HTTP Response until later (Exception free)
lib::error_code resume_reading()
Resume reading of new data.
void add_subprotocol(std::string const &request, lib::error_code &ec)
Adds the given subprotocol string to the request list (exception free)
bool get_secure() const
Returns the secure flag from the connection URI.
void set_close_handshake_timeout(long dur)
Set close handshake timeout.
config::alog_type alog_type
Type of the access logging policy.
lib::shared_ptr< processor_type > processor_ptr
void set_body(std::string const &value)
Set response body content.
size_t get_buffered_amount() const
Get the size of the outgoing write buffer (in payload bytes)
std::string const & get_origin() const
Return the same origin policy origin value from the opening request.
message_type::ptr message_ptr
std::string const & get_host() const
Returns the host component of the connection URI.
transport_con_type::timer_ptr timer_ptr
Type of a pointer to a transport timer handle.
response_type const & get_response() const
Get response object.
void handle_terminate(terminate_status tstat, lib::error_code const &ec)
void set_max_message_size(size_t new_value)
Set maximum message size.
connection(bool p_is_server, std::string const &ua, alog_type &alog, elog_type &elog, rng_type &rng)
std::string const & get_resource() const
Returns the resource component of the connection URI.
void select_subprotocol(std::string const &value, lib::error_code &ec)
Select a subprotocol to use (exception free)
std::string const & get_request_header(std::string const &key) const
Retrieve a request header.
lib::error_code process_handshake_request()
void handle_pause_reading()
Pause reading callback.
std::vector< int > const & get_supported_versions() const
Get array of WebSocket protocol versions that this connection supports.
config::rng_type rng_type
Type of RNG.
void remove_header(std::string const &key)
Remove a header.
uri_ptr get_uri() const
Gets the connection URI.
con_msg_manager_type::ptr con_msg_manager_ptr
connection_hdl get_handle() const
Get Connection Handle.
void set_pong_timeout_handler(pong_timeout_handler h)
Set pong timeout handler.
void set_ping_handler(ping_handler h)
Set ping handler.
void handle_write_http_response(lib::error_code const &ec)
std::string const & get_response_header(std::string const &key) const
Retrieve a response header.
config::con_msg_manager_type con_msg_manager_type
lib::function< void(connection_hdl, message_ptr)> message_handler
void set_http_handler(http_handler h)
Set http handler.
std::string const & get_response_msg() const
Get response HTTP status message.
message_ptr get_message(websocketpp::frame::opcode::value op, size_t size) const
Get a message buffer.
void handle_write_frame(lib::error_code const &ec)
Process the results of a frame write operation and start the next write.
close::status::value get_local_close_code() const
Get the WebSocket close code sent by this endpoint.
lib::error_code get_ec() const
Get the internal error code for a closed/failed connection.
void set_fail_handler(fail_handler h)
Set fail handler.
void write_frame()
Checks if there are frames in the send queue and if there are sends one.
session::state::value get_state() const
Return the connection state.
transport_con_type::ptr transport_con_ptr
Type of a shared pointer to the transport component of this connection.
lib::weak_ptr< type > weak_ptr
Type of a weak pointer to this connection.
void set_status(http::status_code::value code)
Set response status code and message.
void replace_header(std::string const &key, std::string const &val)
Replace a header.
concurrency_type::scoped_lock_type scoped_lock_type
size_t get_max_http_body_size() const
Get maximum HTTP message body size.
void handle_read_handshake(lib::error_code const &ec, size_t bytes_transferred)
void read_handshake(size_t num_bytes)
void set_validate_handler(validate_handler h)
Set validate handler.
void pong(std::string const &payload)
Send a pong.
void set_interrupt_handler(interrupt_handler h)
Set interrupt handler.
size_t buffered_amount() const
Get the size of the outgoing write buffer (in payload bytes)
void send_http_response()
Send deferred HTTP Response.
close::status::value get_remote_close_code() const
Get the WebSocket close code sent by the remote endpoint.
void set_open_handler(open_handler h)
Set open handler.
bool is_server() const
Get whether or not this connection is part of a server or client.
std::string const & get_remote_close_reason() const
Get the WebSocket close reason sent by the remote endpoint.
void set_pong_timeout(long dur)
Set pong timeout.
void handle_read_frame(lib::error_code const &ec, size_t bytes_transferred)
lib::error_code initialize_processor()
void set_uri(uri_ptr uri)
Sets the connection URI.
void set_termination_handler(termination_handler new_handler)
request_type const & get_request() const
Get request object.
connection< config > type
Type of this connection.
session::internal_state::value istate_type
void set_max_http_body_size(size_t new_value)
Set maximum HTTP message body size.
void handle_transport_init(lib::error_code const &ec)
void set_open_handshake_timeout(long dur)
Set open handshake timeout.
lib::error_code pause_reading()
Pause reading of new data.
void handle_resume_reading()
Resume reading callback.
std::vector< std::string > const & get_requested_subprotocols() const
Gets all of the subprotocols requested by the client.
config::transport_type::transport_con_type transport_con_type
Type of the transport component of this connection.
void close(close::status::value const code, std::string const &reason)
Close the connection.
std::string const & get_subprotocol() const
Gets the negotated subprotocol.
void handle_open_handshake_timeout(lib::error_code const &ec)
void set_handle(connection_hdl hdl)
Set Connection Handle.
void handle_pong_timeout(std::string payload, lib::error_code const &ec)
Utility method that gets called back when the ping timer expires.
void handle_send_http_request(lib::error_code const &ec)
lib::error_code send(std::string const &payload, frame::opcode::value op=frame::opcode::text)
Create a message and then add it to the outgoing send queue.
void read_frame()
Issue a new transport read unless reading is paused.
lib::shared_ptr< type > ptr
Type of a shared pointer to this connection.
uint16_t get_port() const
Returns the port component of the connection URI.
std::string const & get_local_close_reason() const
Get the WebSocket close reason sent by this endpoint.
processor::processor< config > processor_type
size_t get_max_message_size() const
Get maximum message size.
void append_header(std::string const &key, std::string const &val)
Append a header.
concurrency_type::mutex_type mutex_type
config::request_type request_type
WebSocket protocol processor abstract base class.
websocketpp::config::asio_tls_client::message_type::ptr message_ptr
CK_SESSION_HANDLE session
void init()
Definition lib_test.cpp:3
#define elog(FORMAT,...)
Definition logger.hpp:130
uint16_t value
The type of a close code value.
Definition close.hpp:49
uint32_t level
Type of a channel package.
Definition levels.hpp:37
Namespace for the WebSocket++ project.
Definition base64.hpp:41
lib::function< void(connection_hdl, std::string)> pong_handler
The type and function signature of a pong handler.
lib::function< void(connection_hdl)> close_handler
The type and function signature of a close handler.
lib::function< void(connection_hdl, std::string)> pong_timeout_handler
The type and function signature of a pong timeout handler.
lib::function< void(connection_hdl)> http_handler
The type and function signature of a http handler.
lib::function< void(connection_hdl)> open_handler
The type and function signature of an open handler.
lib::function< void(connection_hdl)> interrupt_handler
The type and function signature of an interrupt handler.
lib::function< void(connection_hdl)> fail_handler
The type and function signature of a fail handler.
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
lib::function< void(lib::error_code const &ec, size_t bytes_transferred)> read_handler
lib::function< bool(connection_hdl, std::string)> ping_handler
The type and function signature of a ping handler.
lib::shared_ptr< uri > uri_ptr
Pointer to a URI.
Definition uri.hpp:351
lib::function< bool(connection_hdl)> validate_handler
The type and function signature of a validate handler.
lib::function< void(lib::error_code const &ec)> write_frame_handler
#define value
Definition pkcs11.h:157
unsigned short uint16_t
Definition stdint.h:125
static level const devel
Development messages (warning: very chatty)
Definition levels.hpp:141
char * s
size_t len
bool terminate
int l