Skip to content

Commit f20b2e5

Browse files
committed
Merge branch 'develop'
2 parents 875d420 + 650e4c3 commit f20b2e5

File tree

96 files changed

+3678
-740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+3678
-740
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ install_manifest.txt
3232
*.ncb
3333
*/Debug/*
3434
*/*/Debug/*
35+
bin/Debug
3536
*/Release/*
3637
*/*/Release/*
3738
*/RelWithDebInfo/*
3839
*/*/RelWithDebInfo/*
3940

41+
# explicitly allow this path with /debug/ in it
42+
!websocketpp/transport/debug/*
43+
4044
objs_shared/
4145
objs_static/
4246

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ project (websocketpp)
99
cmake_minimum_required (VERSION 2.6)
1010

1111
set (WEBSOCKETPP_MAJOR_VERSION 0)
12-
set (WEBSOCKETPP_MINOR_VERSION 4)
12+
set (WEBSOCKETPP_MINOR_VERSION 5)
1313
set (WEBSOCKETPP_PATCH_VERSION 0)
1414
set (WEBSOCKETPP_VERSION ${WEBSOCKETPP_MAJOR_VERSION}.${WEBSOCKETPP_MINOR_VERSION}.${WEBSOCKETPP_PATCH_VERSION})
1515

Doxyfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PROJECT_NAME = "websocketpp"
3333
# if some version control system is used.
3434

3535

36-
PROJECT_NUMBER = "0.4.0"
36+
PROJECT_NUMBER = "0.5.0"
3737

3838

3939
# Using the PROJECT_BRIEF tag one can provide an optional one line description
@@ -974,7 +974,7 @@ HTML_COLORSTYLE_GAMMA = 148
974974
# page will contain the date and time when the page was generated. Setting
975975
# this to NO can help when comparing the output of multiple runs.
976976

977-
HTML_TIMESTAMP = YES
977+
HTML_TIMESTAMP = NO
978978

979979
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
980980
# documentation will contain sections that can be hidden and shown after the

SConstruct

+16
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ elif env['CXX'].startswith('clang++'):
110110
env.Append(CCFLAGS = ['-Wshadow'])
111111
env.Append(CCFLAGS = ['-Wunused-parameter'])
112112

113+
env.Append(CCFLAGS = ['-Wsometimes-uninitialized'])
114+
env.Append(CCFLAGS = ['-Wuninitialized'])
115+
116+
#env.Append(CCFLAGS = ['-Weverything'])
117+
#env.Append(CCFLAGS = ['-Wno-documentation'])
118+
#env.Append(CCFLAGS = ['-Wno-weak-vtables'])
119+
#env.Append(CCFLAGS = ['-Wno-global-constructors'])
120+
#env.Append(CCFLAGS = ['-Wno-sign-conversion'])
121+
#env.Append(CCFLAGS = ['-Wno-exit-time-destructors'])
122+
123+
124+
125+
113126
# Wpadded
114127
# Wsign-conversion
115128

@@ -239,6 +252,9 @@ debug_server = SConscript('#/examples/debug_server/SConscript',variant_dir = bui
239252
# subprotocol_server
240253
subprotocol_server = SConscript('#/examples/subprotocol_server/SConscript',variant_dir = builddir + 'subprotocol_server',duplicate = 0)
241254

255+
# telemetry_server
256+
telemetry_server = SConscript('#/examples/telemetry_server/SConscript',variant_dir = builddir + 'telemetry_server',duplicate = 0)
257+
242258
if not env['PLATFORM'].startswith('win'):
243259
# iostream_server
244260
iostream_server = SConscript('#/examples/iostream_server/SConscript',variant_dir = builddir + 'iostream_server',duplicate = 0)

changelog.md

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
HEAD
2+
3+
0.5.0 - 2015-01-22
4+
- BREAKING UTILITY CHANGE: Deprecated methods `http::parser::parse_headers`,
5+
`http::response::parse_complete`, and `http::request::parse_complete` have
6+
been removed.
7+
- Security: Disabled SSLv3 in example servers.
8+
- Feature: Adds basic support for accessing HTTP request bodies in the http
9+
handler. #181
10+
- Feature: Adds the ability to register a shutdown handler when using the
11+
iostream transport. This provides a clean interface for triggering the shut
12+
down of external sockets and other cleanup without hooking in to higher level
13+
WebSocket handlers.
14+
- Feature: Adds the ability to register a write handler when using the iostream
15+
transport. This handler can be used to handle transport output in place of
16+
registering an ostream to write to.
17+
- Feature: Adds a new logging policy that outputs to syslog. #386 Thank you Tom
18+
Hughes for submitting the initial version of this policy.
19+
- Improvement: Message payload logging now prints text for text messages rather
20+
than binary.
21+
- Improvement: Overhaul of handshake state machine. Should make it impossible
22+
for exceptions to bubble out of transport methods like `io_service::run`.
23+
- Improvement: Overhaul of handshake error reporting. Fail handler error codes
24+
will be more detailed and precise. Adds new [fail] and [http] logging channels
25+
that log failed websocket connections and successful HTTP connections
26+
respectively. A new aggregate channel package, `alevel::access_core`, allows
27+
enabling connect, disconnect, fail, and http together. Successful HTTP
28+
connections will no longer trigger a fail handler.
29+
- Improvement: Ability to terminate connection during an http handler to cleanly
30+
suppress the default outgoing HTTP response.
31+
- Documentation: Add Sending & Receiving Messages step to chapter one of the
32+
`utility_client` tutorial. Update `utility_client` example to match.
33+
- Cleanup: Removes unused files & STL includes. Adds required STL includes.
34+
Normalizes include order.
35+
- Bug: Fixes a fatal state error when a handshake response is completed
36+
immediately after that handshake times out. #389
37+
- Bug: MinGW fixes; C++11 feature detection, localtime use. #393 Thank you
38+
Schebb for reporting, code, and testing.
39+
- Bug: Fixes an issue where `websocketpp::exception::what()` could return an out
40+
of scope pointer. #397 Thank you fabioang for reporting.
41+
- Bug: Fixes an issue where endpoints were not reset properly after a call to
42+
`endpoint::listen` failed. #390 Thank you wyyqyl for reporting.
43+
144
0.4.0 - 2014-11-04
245
- BREAKING API CHANGE: All WebSocket++ methods now throw an exception of type
346
`websocketpp::exception` which derives from `std::exception`. This normalizes
@@ -174,7 +217,7 @@
174217
- Change default HTTP response error code when no http_handler is defined from
175218
500/Internal Server Error to 426/Upgrade Required
176219
- Remove timezone from logger timestamp to work around issues with the Windows
177-
implimentation of strftime. Thank you breyed for testing and code. #257
220+
implementation of strftime. Thank you breyed for testing and code. #257
178221
- Switch integer literals to char literals to improve VCPP compatibility.
179222
Thank you breyed for testing and code. #257
180223
- Add MSVCPP warning suppression for the bundled SHA1 library. Thank you breyed

examples/broadcast_server/broadcast_server.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <websocketpp/server.hpp>
44

55
#include <iostream>
6+
#include <set>
67

78
/*#include <boost/thread.hpp>
89
#include <boost/thread/mutex.hpp>
@@ -66,10 +67,6 @@ class broadcast_server {
6667
m_server.run();
6768
} catch (const std::exception & e) {
6869
std::cout << e.what() << std::endl;
69-
} catch (websocketpp::lib::error_code e) {
70-
std::cout << e.message() << std::endl;
71-
} catch (...) {
72-
std::cout << "other exception" << std::endl;
7370
}
7471
}
7572

@@ -130,7 +127,7 @@ class broadcast_server {
130127
}
131128
}
132129
private:
133-
typedef std::set<connection_hdl,std::owner_less<connection_hdl>> con_list;
130+
typedef std::set<connection_hdl,std::owner_less<connection_hdl> > con_list;
134131

135132
server m_server;
136133
con_list m_connections;
@@ -153,7 +150,7 @@ int main() {
153150

154151
t.join();
155152

156-
} catch (std::exception & e) {
153+
} catch (websocketpp::exception const & e) {
157154
std::cout << e.what() << std::endl;
158155
}
159156
}

examples/debug_client/debug_client.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <iostream>
3737
#include <chrono>
3838

39-
typedef websocketpp::client<websocketpp::config::asio_tls_client> client;
39+
typedef websocketpp::client<websocketpp::config::asio_client> client;
4040

4141
using websocketpp::lib::placeholders::_1;
4242
using websocketpp::lib::placeholders::_2;
@@ -63,10 +63,11 @@ class perftest {
6363

6464
// Register our handlers
6565
m_endpoint.set_socket_init_handler(bind(&type::on_socket_init,this,::_1));
66-
m_endpoint.set_tls_init_handler(bind(&type::on_tls_init,this,::_1));
66+
//m_endpoint.set_tls_init_handler(bind(&type::on_tls_init,this,::_1));
6767
m_endpoint.set_message_handler(bind(&type::on_message,this,::_1,::_2));
6868
m_endpoint.set_open_handler(bind(&type::on_open,this,::_1));
6969
m_endpoint.set_close_handler(bind(&type::on_close,this,::_1));
70+
m_endpoint.set_fail_handler(bind(&type::on_fail,this,::_1));
7071
}
7172

7273
void start(std::string uri) {
@@ -97,13 +98,26 @@ class perftest {
9798
try {
9899
ctx->set_options(boost::asio::ssl::context::default_workarounds |
99100
boost::asio::ssl::context::no_sslv2 |
101+
boost::asio::ssl::context::no_sslv3 |
100102
boost::asio::ssl::context::single_dh_use);
101103
} catch (std::exception& e) {
102104
std::cout << e.what() << std::endl;
103105
}
104106
return ctx;
105107
}
106108

109+
void on_fail(websocketpp::connection_hdl hdl) {
110+
client::connection_ptr con = m_endpoint.get_con_from_hdl(hdl);
111+
112+
std::cout << "Fail handler" << std::endl;
113+
std::cout << con->get_state() << std::endl;
114+
std::cout << con->get_local_close_code() << std::endl;
115+
std::cout << con->get_local_close_reason() << std::endl;
116+
std::cout << con->get_remote_close_code() << std::endl;
117+
std::cout << con->get_remote_close_reason() << std::endl;
118+
std::cout << con->get_ec() << " - " << con->get_ec().message() << std::endl;
119+
}
120+
107121
void on_open(websocketpp::connection_hdl hdl) {
108122
m_open = std::chrono::high_resolution_clock::now();
109123
m_endpoint.send(hdl, "", websocketpp::frame::opcode::text);

examples/debug_server/debug_server.cpp

+83-1
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,60 @@
3131

3232
#include <websocketpp/config/debug_asio_no_tls.hpp>
3333

34+
// Custom logger
35+
#include <websocketpp/logger/syslog.hpp>
36+
3437
#include <websocketpp/server.hpp>
3538

3639
#include <iostream>
3740

38-
typedef websocketpp::server<websocketpp::config::debug_asio> server;
41+
////////////////////////////////////////////////////////////////////////////////
42+
///////////////// Custom Config for debugging custom policies //////////////////
43+
////////////////////////////////////////////////////////////////////////////////
44+
45+
struct debug_custom : public websocketpp::config::debug_asio {
46+
typedef debug_custom type;
47+
typedef debug_asio base;
48+
49+
typedef base::concurrency_type concurrency_type;
50+
51+
typedef base::request_type request_type;
52+
typedef base::response_type response_type;
53+
54+
typedef base::message_type message_type;
55+
typedef base::con_msg_manager_type con_msg_manager_type;
56+
typedef base::endpoint_msg_manager_type endpoint_msg_manager_type;
57+
58+
/// Custom Logging policies
59+
/*typedef websocketpp::log::syslog<concurrency_type,
60+
websocketpp::log::elevel> elog_type;
61+
typedef websocketpp::log::syslog<concurrency_type,
62+
websocketpp::log::alevel> alog_type;
63+
*/
64+
typedef base::alog_type alog_type;
65+
typedef base::elog_type elog_type;
66+
67+
typedef base::rng_type rng_type;
68+
69+
struct transport_config : public base::transport_config {
70+
typedef type::concurrency_type concurrency_type;
71+
typedef type::alog_type alog_type;
72+
typedef type::elog_type elog_type;
73+
typedef type::request_type request_type;
74+
typedef type::response_type response_type;
75+
typedef websocketpp::transport::asio::basic_socket::endpoint
76+
socket_type;
77+
};
78+
79+
typedef websocketpp::transport::asio::endpoint<transport_config>
80+
transport_type;
81+
82+
static const long timeout_open_handshake = 0;
83+
};
84+
85+
////////////////////////////////////////////////////////////////////////////////
86+
87+
typedef websocketpp::server<debug_custom> server;
3988

4089
using websocketpp::lib::placeholders::_1;
4190
using websocketpp::lib::placeholders::_2;
@@ -44,6 +93,33 @@ using websocketpp::lib::bind;
4493
// pull out the type of messages sent by our config
4594
typedef server::message_ptr message_ptr;
4695

96+
bool validate(server *, websocketpp::connection_hdl) {
97+
//sleep(6);
98+
return true;
99+
}
100+
101+
void on_http(server* s, websocketpp::connection_hdl hdl) {
102+
server::connection_ptr con = s->get_con_from_hdl(hdl);
103+
104+
std::string res = con->get_request_body();
105+
106+
std::stringstream ss;
107+
ss << "got HTTP request with " << res.size() << " bytes of body data.";
108+
109+
con->set_body(ss.str());
110+
con->set_status(websocketpp::http::status_code::ok);
111+
}
112+
113+
void on_fail(server* s, websocketpp::connection_hdl hdl) {
114+
server::connection_ptr con = s->get_con_from_hdl(hdl);
115+
116+
std::cout << "Fail handler: " << con->get_ec() << " " << con->get_ec().message() << std::endl;
117+
}
118+
119+
void on_close(websocketpp::connection_hdl) {
120+
std::cout << "Close handler" << std::endl;
121+
}
122+
47123
// Define a callback to handle incoming messages
48124
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
49125
std::cout << "on_message called with hdl: " << hdl.lock().get()
@@ -74,6 +150,12 @@ int main() {
74150
// Register our message handler
75151
echo_server.set_message_handler(bind(&on_message,&echo_server,::_1,::_2));
76152

153+
echo_server.set_http_handler(bind(&on_http,&echo_server,::_1));
154+
echo_server.set_fail_handler(bind(&on_fail,&echo_server,::_1));
155+
echo_server.set_close_handler(&on_close);
156+
157+
echo_server.set_validate_handler(bind(&validate,&echo_server,::_1));
158+
77159
// Listen on port 9012
78160
echo_server.listen(9012);
79161

examples/echo_server/echo_server.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ int main() {
5050

5151
// Start the ASIO io_service run loop
5252
echo_server.run();
53-
} catch (const std::exception & e) {
53+
} catch (websocketpp::exception const & e) {
5454
std::cout << e.what() << std::endl;
55-
} catch (websocketpp::lib::error_code e) {
56-
std::cout << e.message() << std::endl;
5755
} catch (...) {
5856
std::cout << "other exception" << std::endl;
5957
}

examples/echo_server_both/echo_server_both.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ context_ptr on_tls_init(websocketpp::connection_hdl hdl) {
4646
try {
4747
ctx->set_options(boost::asio::ssl::context::default_workarounds |
4848
boost::asio::ssl::context::no_sslv2 |
49+
boost::asio::ssl::context::no_sslv3 |
4950
boost::asio::ssl::context::single_dh_use);
5051
ctx->set_password_callback(bind(&get_password));
5152
ctx->use_certificate_chain_file("server.pem");

examples/echo_server_tls/echo_server_tls.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ context_ptr on_tls_init(websocketpp::connection_hdl hdl) {
3838
try {
3939
ctx->set_options(boost::asio::ssl::context::default_workarounds |
4040
boost::asio::ssl::context::no_sslv2 |
41+
boost::asio::ssl::context::no_sslv3 |
4142
boost::asio::ssl::context::single_dh_use);
4243
ctx->set_password_callback(bind(&get_password));
4344
ctx->use_certificate_chain_file("server.pem");

examples/iostream_server/iostream_server.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,8 @@ int main() {
8282
}
8383
con->eof();
8484
}
85-
} catch (const std::exception & e) {
85+
} catch (websocketpp::exception const & e) {
8686
std::cout << e.what() << std::endl;
87-
} catch (websocketpp::lib::error_code e) {
88-
std::cout << e.message() << std::endl;
89-
} catch (...) {
90-
std::cout << "other exception" << std::endl;
9187
}
9288
log.close();
9389
}

examples/sip_client/sip_client.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ int main(int argc, char* argv[]) {
7878

7979
std::cout << "done" << std::endl;
8080

81-
} catch (const std::exception & e) {
81+
} catch (websocketpp::exception const & e) {
8282
std::cout << e.what() << std::endl;
83-
} catch (websocketpp::lib::error_code e) {
84-
std::cout << e.message() << std::endl;
85-
} catch (...) {
86-
std::cout << "other exception" << std::endl;
8783
}
8884
}

examples/subprotocol_server/subprotocol_server.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ int main() {
4242
s.start_accept();
4343

4444
s.run();
45-
} catch (const std::exception & e) {
45+
} catch (websocketpp::exception const & e) {
4646
std::cout << e.what() << std::endl;
47-
} catch (websocketpp::lib::error_code e) {
48-
std::cout << e.message() << std::endl;
49-
} catch (...) {
50-
std::cout << "other exception" << std::endl;
5147
}
5248
}

0 commit comments

Comments
 (0)