Compare commits

...

1588 Commits

Author SHA1 Message Date
Peter Thorson c612a35f06 Set version flags for 0.8.0 release 2018-07-12 07:50:48 -05:00
Peter Thorson 99d169f586 Update changelog for recent PRs 2018-07-12 07:46:21 -05:00
Peter Thorson 241741ba01 Merge pull request #727 from bauerj/patch-1
Make HTTP Connection header capitalized
2018-07-12 07:27:05 -05:00
Johann Bauer 702b6a919b Make HTTP Connection header capitalized
This is what other implementations do and what the example in RFC 6455 uses.
2018-06-18 12:46:01 +02:00
Peter Thorson 19cad9925f credits 2017-09-24 10:48:12 -05:00
Peter Thorson c4050979c3 tcp_pre_bind_handler returns a lib::error_code not an asio::error_code. These are sometimes the same but not always. Fix ensures that the error code types always match correctly no matter what they are. Update test suite to reflect adjusted behavior 2017-09-24 10:44:21 -05:00
Peter Thorson 7e8c8a8fad Fix preprocessor syntax issue 2017-09-24 09:56:21 -05:00
Peter Thorson 88de392422 Merge pull request #652 from vadz/preserve-asio-errors
Preserve ASIO errors if possible
2017-09-24 09:52:52 -05:00
Peter Thorson e79e0d1f94 Merge branch 'develop' of https://github.com/zaphoyd/websocketpp into develop 2017-09-24 09:27:47 -05:00
Peter Thorson bc12b81b29 Merge branch 'pr/608' into develop
# Conflicts:
#	changelog.md
2017-09-24 09:27:42 -05:00
Peter Thorson 8bc11bdf24 credits 2017-09-24 09:19:50 -05:00
Peter Thorson 1cb045d946 Add pointers in the docs to new mingw support 2017-09-24 09:17:34 -05:00
Peter Thorson 2a36e41a9a Remove auto selection of mingw-std-threads when MinGW is detected. Increase the priority of mingw-std-threads given its optional status. 2017-09-24 09:17:17 -05:00
Peter Thorson 0e1fc63b83 remove submodule 2017-09-24 09:16:05 -05:00
Peter Thorson 0b0871d879 remove submodules 2017-09-24 08:55:47 -05:00
Peter Thorson 20c67910e1 Merge pull request #658 from gjasny/drop-unused-members
Drop unused class members
2017-09-24 08:49:12 -05:00
Peter Thorson e943c9e1ed credits for patch 2017-09-24 08:44:28 -05:00
Peter Thorson 749b119b6b Merge pull request #665 from gegles/develop
Fix compile issues for ASIO_STANDALONE
2017-09-24 08:41:15 -05:00
Guillaume Egles e9c65467b3 Fix compile issues for ASIO_STANDALONE 2017-08-30 14:46:56 -07:00
Gregor Jasny b34a1786bc Drop unused class members 2017-07-04 09:31:37 +02:00
Peter Thorson e50ed8c1b1 update changelog for PR 2017-06-11 17:49:41 -05:00
Peter Thorson 67224f71b5 Merge pull request #636 from gjasny/remove-undefined-behaviour
Avoid undefined behaviour at circular shift
2017-06-11 17:47:47 -05:00
Peter Thorson 0b2e14ee3a Merge branch 'pr/589' into develop 2017-06-11 17:44:02 -05:00
Peter Thorson 1cb9666036 Update changelog for PR 2017-06-11 17:43:09 -05:00
Peter Thorson cb3d7de91f Remove deprecated features to allow compiling with C++17 compilers fixes #592 2017-06-11 17:37:14 -05:00
Peter Thorson 9baab8faa9 Normalize line endings to unix format fixes #644 2017-06-11 17:27:41 -05:00
Peter Thorson 6330286ad5 Use separate buffers for compression and decompression to prevent corruption when reading and writing from separate threads. references #633 references #615 2017-06-11 17:24:51 -05:00
Peter Thorson cb4cf66911 Merge branch 'pr/634' into develop 2017-06-11 16:46:31 -05:00
Peter Thorson 99e1a99633 change log update for PR 2017-06-11 16:46:18 -05:00
Peter Thorson 96b2d42c83 Merge branch 'pr/638' into develop 2017-06-11 16:39:32 -05:00
Peter Thorson bc04ae4f5f update changelog for PR 2017-06-11 16:37:46 -05:00
Peter Thorson ee74047c2d Merge pull request #645 from alex-che/integration_tests_sleep
Fix refused client connection due to servers not yet started
2017-06-11 16:34:49 -05:00
Peter Thorson 2819d364d9 Merge branch 'develop' into integration_tests_sleep 2017-06-11 16:31:21 -05:00
Peter Thorson d282738c81 Merge branch 'pr/643' into develop 2017-06-11 16:28:58 -05:00
Peter Thorson a32eb0887b change log entry for PR 2017-06-11 16:28:47 -05:00
Peter Thorson 6645fcb390 Merge pull request #646 from alex-che/timers_tests_sleep
Fix the tls_handshake_timeout unit test failing due to server thread …
2017-06-11 16:18:00 -05:00
Peter Thorson 29bb4ada91 Merge branch 'pr/647' into develop 2017-06-11 16:16:38 -05:00
Peter Thorson ac9164c3b5 update changelog for PR 2017-06-11 16:16:13 -05:00
Peter Thorson 4cab5e5c0c minor adjustments to recent extension negotiation related fixes, refactor a bit more extension negotiation code to be simpler 2017-06-11 16:13:25 -05:00
Peter Thorson 16d126ee61 Remove custom handling of SSL_R_SHORT_READ errors. fixes #599 2017-06-11 15:41:06 -05:00
Peter Thorson 9ddb300d87 Update permessage-deflate support to reflect that zlib doesn't support a 256 bit window. Improve extension negotiation error checking and documentation. fixes #596 fixes #653 2017-06-11 15:24:43 -05:00
Vadim Zeitlin 81ef065ccf Preserve ASIO errors if possible in asio::endpoint too
This was already done in asio::xxx_socket::connection methods by using
translate_ec() which allowed to preserve the error code when possible (i.e.
when using Boost.ASIO with Boost.System or standalone ASIO with C++11
std::error_code), but errors also can happen in endpoint methods such as
handle_connect(), where they were totally lost and replaced with a rather
useless error::pass_through.

With these changes, the real error codes are preserved and applications using
the library can give more useful error messages if connection fails.
2017-06-04 16:50:14 +02:00
Vadim Zeitlin e6e14df950 Make asio::connection::xxx_socket::translate_ec() methods static
These methods don't need any object to operate on, so make them static to
allow calling them without an actual connection object at hand.
2017-06-04 01:56:59 +02:00
Alex Korotkin 527f401049 Fix unitialized shared_ptr in mock_endpoint 2017-05-17 09:54:14 +03:00
Alex Korotkin 00456642fa Fix the tls_handshake_timeout unit test failing due to server thread not having enough time to start 2017-05-17 09:48:33 +03:00
Alex Korotkin 7be37565ca Fix refused client connection due to servers not yet started
The server thread in a unit test may not have enough time to start and the
ongoing client connection will be refused. Fix this by adding sleep.
2017-05-16 18:13:11 +03:00
Alex Korotkin 5675036891 Fix unit test timers clashing between tests
If unit tests run long enough, then test timers fired for former unit tests can start to fail while running latter unit tests.
2017-05-16 16:51:43 +03:00
Alex Korotkin 4b6cfed3fc "stdint header included to fix uintXX_t compilation error" 2017-05-06 13:11:17 +03:00
Gregor Jasny 6578aaea02 Avoid undefined behaviour at circular shift
Clang UBSAN complains about 64 bit wide shifts.
2017-04-09 23:59:23 -07:00
Gregor Jasny 229134aa95 Add pre bind handler for listen socket
Within this handler socket options like IPV6_ONLY could be set.
2017-04-04 22:34:11 +02:00
Peter Taylor c7bef866e4 Fixed Capatialisation issue with submodule 2016-12-11 11:31:08 +00:00
emersont1 3ad502916e Added MinGW threading Capability 2016-12-08 18:41:49 +00:00
jbwdevries 7451e0c58b Merge pull request #1 from ronneke1996/implement_close_code_1014
Fixed typo in error message
2016-10-18 18:46:44 +02:00
Ron Nabuurs facb698845 Fixed typo in error message 2016-10-18 16:59:38 +02:00
Peter Thorson 37ce8abc77 Merge branch 'pr/593' into develop 2016-10-14 08:28:55 -05:00
Peter Thorson abf927bb24 Fix some bugs, normalize code style, update documentation, add tests
Method needs to be public to be useful, updated return type to const
reference for efficiency
2016-10-14 08:27:06 -05:00
Jupp Müller e1f75756d1 Expose HTTP request headers
This change allows users to get a full list of HTTP request headers
allowing libraries that build on top of websocketpp to pass those on
to their users without exposing access to the already existing getter
methods.
2016-10-14 13:17:28 +02:00
Johan de Vries f94b3c0e4c Implemented close code 1014
Also adds two missing messages to get_string()
2016-10-10 10:05:15 +02:00
Peter Thorson 322e3bafbf Update telemetry_client to use Sleep on windows references #574 2016-10-04 07:41:02 -05:00
Peter Thorson 9019af0070 Add FAQ entry 2016-10-03 19:04:27 -05:00
Peter Thorson e65b277017 Remove catching websocketpp::lib::error_code in examples, fixes #584
A few versions ago the library was standardized to only throw
websocketpp::exception. Not all example code was updated.
2016-10-03 19:04:12 -05:00
Peter Thorson 8434139b67 Add first draft of print_client and print_client_tls 2016-06-10 07:24:36 -04:00
Peter Thorson d4a4b79684 update changelog for recent PR 2016-06-09 09:22:17 -04:00
Peter Thorson 6b09310479 Merge pull request #553 from yeswalrus/fix-tls-crash
Fix server_endpoint crash on connection failure
2016-06-09 09:08:12 -04:00
Peter Thorson 2b310fa80b Merge branch 'develop' of https://github.com/zaphoyd/websocketpp into develop 2016-05-25 08:11:20 -04:00
Peter Thorson 0bb33e4bca Change default listen backlog to socket_base::max_connections from 0, fixes #549
After a change in Linux Kernel 4.4 the value of 0 causes all
connections to be rejected rather than the default value being used.
The default is now the asio::socket_base::max_connections value instead
(which is the default asio uses when no value is provided).
Documentation has been updated accordingly.
2016-05-25 08:10:47 -04:00
Walter Gray ebd0afd67d Check the return of get_connection, raise an appropriate error if it failed. 2016-05-19 16:00:20 -07:00
Walter Gray 5f42305bbd remove trailing whitespaces 2016-05-19 13:47:20 -07:00
Peter Thorson a2f182733a Merge pull request #550 from wal-rus/fix-cmake
Fix CMake config files
2016-05-18 08:38:11 -04:00
Walter Gray 59fb9ece5d Added interface target to config file for cmake versions > 3.0 2016-05-11 16:54:41 -07:00
Walter Gray 73c3b81411 Added include directories to targets (How was this ever working?) 2016-05-11 16:54:40 -07:00
Walter Gray cc851aa167 remove whitespace at end of lines in CMakeHelpers.cmake 2016-05-11 16:54:39 -07:00
Walter Gray 0f2df92ae4 Use CMakePackageConfigHelpers, make websocketpp-config.cmake.in relocatable 2016-05-11 16:54:39 -07:00
Walter Gray 6b702cc050 Updated minimum required version to 2.8.8, Added VERSION argument to project if supported. 2016-05-11 16:54:38 -07:00
Walter Gray 92c1f0c415 Fix default CMAKE_INSTALL_PREFIX setting on windows 2016-05-10 13:44:25 -07:00
Peter Thorson 9e5163364f Add logging reference documentation 2016-04-27 09:00:30 -04:00
Peter Thorson 8f0fab3e77 Update docs & FAQ 2016-04-23 08:05:01 -04:00
Peter Thorson 94fe989840 Store loggers in shared pointers references #501 #537
adds related changelog entry and fix one overzealous find and replace
operation.
2016-04-06 09:38:45 -04:00
Peter Thorson 9da5ac93ec Merge pull request #539 from jupp0r/feature/shutdown-fix-for-shared-ioservice
Fix shutdown bugs by holding loggers in shared_ptrs
2016-04-06 09:27:35 -04:00
Peter Thorson 891a7a5ed5 documentation 2016-04-03 11:39:46 -04:00
Jupp Müller 1013aa89bc Fix shutdown bugs by holding loggers in shared_ptrs
This change fixes a shutdown crash occuring when using an
external io_service to drive a websocketpp server. The crash
itself is reproduced by the following code:

```

int main(int argc, const char * argv[])
{
    boost::asio::io_service ioService;
        std::unique_ptr<boost::asio::io_service::work> ioServiceWork(new boost::asio::io_service::work(ioService));
            std::thread ioServiceThread(boost::bind(&boost::asio::io_service::run, &ioService));

    {
        auto server = std::unique_ptr<websocketpp::server<websocketpp::config::asio>>(new websocketpp::server<websocketpp::config::asio>());
        server->init_asio(&ioService);
        server->listen(0);
        server->start_accept();

        server->stop();
    }

    ioServiceWork.reset();
    ioService.stop();
    ioServiceThread.join();

    return 0;
}
```

The cause of the crash is a dangling pointer to alog or elog objects in endpoints.
This is mitigated by storing logging objects as shared_ptrs. This ensures that
they are kept alive and able to log even if their owning structures have already
been deallocated.
2016-03-31 16:49:16 +02:00
Peter Thorson 366679b50a Update docs and changelog 2016-03-31 09:57:45 -04:00
Peter Thorson 94cc1ec5cb Fix an issue detecting which version of the chrono library to use references #512
If we are using Boost for Asio, the
websocketpp::lib::asio::milliseconds function should return a chrono
milliseconds object using whatever chrono library boost is using.

Boost does its own autodetection of the std::chrono library and prefers
it over boost::chrono when available. This change checks which chrono
library boost is using and uses that. Otherwise it falls back to the
websocketpp default.
2016-03-31 09:55:07 -04:00
Peter Thorson 6f128a5499 Move socket_init_handler from pre_init to init_asio #530
pre_init happens after bind/listen/accept, preventing socket options
that affect those system calls from being set in time.
2016-02-26 06:37:34 -05:00
Peter Thorson f5d14f3ad3 Bump develop branch version 2016-02-26 06:30:44 -05:00
Peter Thorson 918745a7ea Add test case for un-setting a handler (with NULL) 2016-02-26 06:20:53 -05:00
Peter Thorson 378437aecd Merge branch 'develop' 2016-02-22 08:30:10 -05:00
Peter Thorson cc7d74d8d0 Set version flags for release 2016-02-22 08:28:27 -05:00
Peter Thorson b154ac5907 Add FAQ entry 2016-02-22 08:28:05 -05:00
Peter Thorson 0348510c8d Fix minor issue in hybi00 subprotocol support patch. Update changelog for recent PRs 2016-02-21 18:30:58 -05:00
Peter Thorson a495c8c529 Merge branch 'develop' of https://github.com/zaphoyd/websocketpp into develop 2016-02-21 18:25:14 -05:00
Peter Thorson fabf8bf1ca clarified debugging output in connection read_handshake 2016-02-21 18:24:57 -05:00
Peter Thorson 3f913f97ef update tls version used in tls timer tests 2016-02-21 18:24:37 -05:00
Peter Thorson ffaeba2ec7 switch comment style in connection tests 2016-02-21 18:24:19 -05:00
Peter Thorson db304bfec4 Remove the use of cached read and write handlers in the asio transport. references #490 #525
There isn't a clean way to implement this performance optimization without adding global state/locking, which performs worse. This should fix
2016-02-21 18:23:58 -05:00
Peter Thorson d3bec51d25 Merge pull request #518 from lobermann/hixie76-hybi00-subprotocol-support
added subprotocol support for hybi00 / hixie76
2016-02-21 13:07:24 -05:00
Peter Thorson 8b672f7372 Merge pull request #524 from xavigibert/fix-uri
Fixed uri validator by checking its length.
2016-02-21 13:04:18 -05:00
Xavier Gibert Serra a4a79f6bf6 Fixed uri validator. This bug caused asan error heap-buffer-overflow when passing a short address. 2016-02-18 08:45:20 -08:00
Peter Thorson 9dc013a3aa Add an FAQ entry explaining how to use permessage-deflate in 0.6.0 and 0.7.0 2016-02-18 09:11:19 -05:00
Peter Thorson 931ad40b5f documentation & friend updates 2016-02-18 08:46:15 -05:00
Peter Thorson 842f745e24 Add echo_client example 2016-02-18 08:45:31 -05:00
Lukas Obermann e6f8766707 added subprotocol support for hybi00 / hixie76
This was missing but it is described in the RFC here
https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00#section-1.9
2016-02-10 17:07:02 +01:00
Peter Thorson 17a2647454 Apply tentative fix for explicitly destroying objects that use io_service before it is deleted 2016-02-08 07:32:57 -05:00
Peter Thorson 323dec4efc Merge branch 'strand-fix-1' into develop 2016-02-08 07:31:41 -05:00
Peter Thorson ee343fb282 Adjust use of strand to work better with composite asio operations. references #459
particularly affected TLS servers and connection close behavior
2016-02-08 07:31:06 -05:00
Peter Thorson b76422aa7a explicitly delete work and resolver object before deleting io_service references #510 2016-02-07 11:58:04 -05:00
Peter Thorson 563fcc6b45 wrap TLS async_shutdown in a strand references #459 #466 2016-02-07 11:26:00 -05:00
Peter Thorson b6014cc79b FAQ & Change log minor update 2016-02-02 09:39:12 -05:00
Peter Thorson d917f0924b Remove execute permission from sha1.hpp fixes #489 2016-01-31 15:14:44 -05:00
Peter Thorson e036a5aeab Also fix this use of auto_ptr 2016-01-31 15:11:33 -05:00
Peter Thorson ed335a37b5 Replace deprecated use of auto_ptr when unique_ptr is available 2016-01-31 11:07:36 -05:00
Peter Thorson bb4cbf3d03 Merge branch 'develop' of https://github.com/zaphoyd/websocketpp into develop 2016-01-19 09:34:43 -05:00
Peter Thorson a388817606 Initial work on utility_server tutorial 2016-01-19 09:33:18 -05:00
Peter Thorson b373f1ea6b Merge pull request #509 from mgeier/no-get-uri
telemetry_server: Remove unnecessary call to get_uri()
2016-01-19 09:30:23 -05:00
Peter Thorson 28448c77a5 Merge pull request #507 from mgeier/unneeded-typedef
Remove unneeded typedef from telemetry_server example
2016-01-19 09:29:07 -05:00
Peter Thorson ae097d6a93 Merge pull request #508 from mgeier/lock-guard
broadcast_server: replace explicit unlock() by scoped unlock
2016-01-19 09:28:56 -05:00
Matthias Geier 02f0026a00 telemetry_server: Remove unnecessary call to get_uri() 2016-01-19 13:22:34 +01:00
Matthias Geier aac65bdfd0 broadcast_server: replace explicit unlock() by scoped unlock
Also: Replace some instances of unique_lock with lock_guard.
2016-01-19 12:31:23 +01:00
Matthias Geier 7b368e67ed Remove unneeded typedef from telemetry_server example 2016-01-19 10:29:37 +01:00
Peter Thorson d0802994d8 Merge branch 'pr/502' into develop 2016-01-14 09:12:02 -05:00
Peter Thorson 20cc197967 Fix a few other misc test related things 2016-01-12 10:51:59 -05:00
Gregor Jasny 89df55c577 Register tests to CTest 2016-01-05 09:51:15 +01:00
Peter Thorson 9713455e94 Fix TLS+Asio Standalone builds 2015-12-20 09:36:46 -05:00
Peter Thorson 044eda9cc4 Merge pull request #493 from jchampio/dev/cancel_socket
Always log errors when cancelling sockets
2015-12-19 11:52:24 -05:00
Peter Thorson fc6ec59ab8 more travis updates 2015-12-17 08:11:23 -05:00
Peter Thorson a01cce3b1a travis update 2015-12-17 07:32:26 -05:00
Peter Thorson e1b39037f7 travis config update 2015-12-17 07:30:00 -05:00
Peter Thorson f54fb0669b more docs 2015-12-17 07:29:51 -05:00
Peter Thorson 935c8a3264 Begin update to migrate manual content into the git repository
The goal here is to get all the documentation in one place including
the class reference, text based manual, tutorials, etc.
2015-12-16 10:03:14 -05:00
Peter Thorson 1e12e7aff8 use c++11 thread support on recent visual studio versions (really) 2015-12-15 19:17:11 -05:00
Peter Thorson bda1bd14cb use c++11 thread support on recent visual studio versions 2015-12-15 19:13:37 -05:00
Jacob Champion 5f52127cf7 Always log errors during socket cancel
cancel_socket_checked(), which logs any received errors, is now called
consistently instead of the lower-level cancel_socket().
2015-12-15 15:06:01 -08:00
Jacob Champion 999add0c4b Improve socket cancellation error messages
log_err() includes information about the error code.
2015-12-15 15:04:41 -08:00
Jacob Champion f7448bb1b0 Write to the error log for socket cancel failures
Previously an elevel entry was being written to an alog (possible
copy-paste error?).
2015-12-15 14:40:10 -08:00
Peter Thorson ed45dcc617 Fix an issue where the wrong type of strand was being created. 2015-11-24 10:22:54 -05:00
Peter Thorson 7f19b6ea95 Merge pull request #485 from Meoo/patch-1
Fix make_shared using the wrong strand type
2015-11-24 10:04:03 -05:00
Bastien Brunnenstein 5b99feef7f Fix make_shared using the wrong strand type
Fix compilation with standalone ASIO (#462), where asio::strand and asio::io_service::strand are separate types.
This is the correct type, as m_strand is a ``lib::shared_ptr<lib::asio::io_service::strand>``
2015-11-24 15:24:52 +01:00
Peter Thorson b85affddf4 Test how some doxygen compatible markup behaves on github 2015-11-05 08:29:04 -05:00
Peter Thorson 5500aef4ce Allow accessing the local endpoint when using the Asio transport. fixes #458 2015-11-05 06:33:15 -05:00
Peter Thorson 4e2fb75d07 Removes non-standards compliant masking behavior. fixes #469, fixes #395 2015-10-30 09:26:28 -04:00
Peter Thorson 6a94162264 Fix error handling in debug_client fixes #473 2015-10-30 08:45:32 -04:00
Peter Thorson 536db87c53 Merge branch 'pr/468' into develop 2015-09-30 09:59:11 -04:00
Peter Thorson 39c5f3ae3d Update changelog 2015-09-30 09:56:57 -04:00
vladon cd4af122c0 avoid unnecessary empty strings ("") in favor of clear() and empty() (performance) 2015-09-29 21:36:41 +03:00
Peter Thorson b6817e4c7e Actually have the response status getters work; also tests 2015-09-19 10:54:50 -04:00
Peter Thorson 72e55a76b5 remove alias for better compatibility with older compilers 2015-09-17 10:09:28 -04:00
Peter Thorson 93b75ccc7d Add get_status and get_response methods to connection fixes #465 2015-09-17 10:09:07 -04:00
Peter Thorson 3e8dbf767d Add example demonstrating external io_service 2015-09-17 08:11:48 -04:00
Peter Thorson 3c77ce3cc7 Fix race condition resulting in corruption of responses sent from non-blocking HTTP handers
The HTTP request processing code was expecting that the http response
state would be `deferred` after a call to an HTTP handler that deferred
the response. If, in addition to deferring, you also sent the response
the HTTP state advanced past `deferred` to `response_written`. This
doesn't easily show up in unit tests because the bug requires that the
async write still be in flight and the connection still be open when
the HTTP handler returns.

An asynchronous network transport (like Asio) combined with a
sufficiently large message that Asio yields control back to WebSocket++
before the response is fully written will trigger a second write on the
same connection while the first is in flight. This is not allowed per
the Asio spec and results in undefined behavior.

The HTTP request processing code now checks if the http state is init,
i.e. not deferred and no response has been started rather than just if
it was deferred.
2015-09-09 10:14:37 -04:00
Peter Thorson 54ce641d02 remove tabs 2015-08-25 09:30:00 -04:00
Peter Thorson e0bd3f7e95 Address an issue where an exception could be thrown when a socket gets canceled on Windows XP #460
This fix switches to using the non-exception variant of socket::cancel
and logging the error instead of throwing it. There is a chance that
something else will need to be addressed as a result of this change as
some async operations might not be cancelled? I believe everything in
question has timeouts that will trigger operation cancellation at some
point anyways.
2015-08-25 09:03:00 -04:00
Peter Thorson fb829e0895 Misc changes related to translation of asio transport errors #448 2015-08-20 10:14:55 -04:00
Peter Thorson f9dbc0fd9d Merge branch 'pr/456' into develop 2015-08-06 09:12:05 -04:00
Peter Thorson 0b2b77e4ad update changelog 2015-08-06 09:11:50 -04:00
Eli Fidler 15c78afbf4 fix crash in strip_lws()
Before this fix, a malicious client could cause a websocketpp server to create an invalid std::string.
2015-08-04 12:01:14 -04:00
Peter Thorson 4b18214eda Add preliminary support for C++11 features in Visual Studio 2015 2015-08-01 12:38:18 -04:00
Peter Thorson e80673278f Merge branch 'pr/454' into develop 2015-07-29 09:29:37 -04:00
Peter Thorson 95551e7e94 code style & change log update for PR 2015-07-29 09:28:22 -04:00
Peter Thorson 22918a3992 Merge branch 'permessage-deflate' into develop
Conflicts:
	Doxyfile
	examples/utility_client/CMakeLists.txt
	websocketpp/version.hpp
2015-07-29 09:12:21 -04:00
Peter Thorson 9b09b0b481 Merge branch 'pr/449' into develop 2015-07-29 08:59:14 -04:00
Peter Thorson ef380f7fff Add CMake build support for examples and tests, zlib dependencies 2015-07-29 08:57:56 -04:00
Mark Grimes 1f504001d2 Use smart pointer to hold new io_service temporarily in case of errors 2015-07-29 12:36:22 +01:00
Peter Thorson c54f2abaab utility client build scripts 2015-07-23 07:53:51 -04:00
Peter Thorson 3580530902 Miscellaneous changes
- Updates code style
- Adds some tags for future exception free work
- Fix utility client build scripts
2015-07-23 07:53:31 -04:00
Thijs Wenker bc7ad6550e fixed typo 2015-07-16 12:18:32 +02:00
Thijs Wenker d3fe51fa39 Added missing CMake files, organized the CMake structure between test and example directories using the global variable USE_FOLDERS 2015-07-16 12:17:59 +02:00
Thijs Wenker 7514c82c92 CMake: properly include examples and tests with macro (added unit_test_framework dependency for unit tests) 2015-07-16 11:38:38 +02:00
Peter Thorson dabf32a668 Better std::chrono autodetection for Visual Studio 2015-06-05 08:49:07 -04:00
Peter Thorson 0d7052d2ae Merge branch 'master' into permessage-deflate
Update permessage-deflate to track latest release version.
2015-06-03 09:21:06 -04:00
Peter Thorson 39497aaa61 reset dev branch for work on next version 2015-06-02 08:59:10 -04:00
Peter Thorson c5510d6de0 Merge branch 'develop'
Conflicts:
	CMakeLists.txt
	Doxyfile
	changelog.md
	readme.md
	websocketpp/version.hpp
2015-06-02 08:55:24 -04:00
Peter Thorson f931734369 prep for release 2015-06-02 07:19:59 -04:00
Peter Thorson af792aeaba Update changelog 2015-06-02 07:02:48 -04:00
Peter Thorson 2af2135d82 Merge pull request #432 from rec/develop
Fix dangling pointer and message in error.hpp.
2015-06-02 06:59:04 -04:00
Tom Ritchford f2b38d5634 Fix dangling pointer and message in error.hpp. 2015-05-27 19:18:24 -04:00
Peter Thorson 1b9e40040c update readme 2015-05-10 21:36:19 -04:00
Peter Thorson 8893faff53 Removes an unnecessary mutex lock in get_con_from_hdl 2015-05-10 21:36:19 -04:00
Peter Thorson 430fb82e76 Fix typo in cmake files 2015-05-10 21:36:19 -04:00
Peter Thorson 01d4109ae8 Merge pull request #428 from timrau/develop
Fix grammar
2015-05-07 09:02:24 -04:00
timrau 4cc678ee93 Fix grammar 2015-05-07 21:00:09 +08:00
Peter Thorson acb53a379c Refactor deferred http handler support to better match the library conventions 2015-04-29 20:00:20 -04:00
Peter Thorson c18f210ea3 Allow deferring the sending of an HTTP response. references #425
This allows processing of long running http handlers to defer their
response until it is ready without blocking the network thread.
2015-04-29 19:28:36 -04:00
Peter Thorson f469b90bfc update changelog credit 2015-04-29 19:24:04 -04:00
Peter Thorson 9d95501536 changelog update 2015-04-25 13:32:33 -04:00
Peter Thorson 9351e73e90 initial sketch of TLS tutorial 2015-04-25 12:41:14 -04:00
Peter Thorson b817c4499e Updates echo_server_tls reference TLS settings 2015-04-25 12:28:28 -04:00
Peter Thorson 7829de34a3 Update changelog 2015-04-25 12:26:16 -04:00
Peter Thorson 6973f02d1c make sure boost version is loaded before using it 2015-04-25 12:25:17 -04:00
Peter Thorson 31b75714bd Update common/chrono.hpp to latest spec 2015-04-25 12:24:53 -04:00
Peter Thorson 257b5ac8e5 add boost chrono to travis dependencies 2015-04-25 07:33:26 -04:00
Peter Thorson 769fe89533 Major refactor to support standalone Asio and remove Boost dependencies
It is now possible to use WebSocket++’s asio transport using only
standalone asio by defining ASIO_STANDALONE before including any
WebSocket++ headers.
2015-04-25 07:17:28 -04:00
Peter Thorson d670d69c6e Refactor boost dependencies
Introduces a common type_traits header that supplies aligned_storage
using either boost or C++11.

removes unused boost header boost/array.hpp

removes usage of boost::noncopyable in favor of C++11 deleted copy
constructor/operators
2015-04-24 09:40:59 -04:00
Peter Thorson 2c843b9343 echo_server now checks for a special command to stop listening for new connections 2015-04-14 08:14:47 -04:00
Peter Thorson d076e38e00 properly set opcode on outgoing close frames 2015-04-14 07:58:34 -04:00
Peter Thorson 4331de8a29 Add missing header references #418 2015-04-14 06:56:30 -04:00
Peter Thorson 6dde40d96e Merge pull request #413 from rec/public-accessor
Make transport::asio::connection::get_strand() public.
2015-04-14 06:50:09 -04:00
Peter Thorson d68fd03e40 date fix 2015-04-02 09:56:22 -04:00
Peter Thorson e161ffde69 permessage deflate error category utility methods should be inline 2015-04-02 09:39:03 -04:00
Tom Ritchford dc313effa5 Make transport::asio::connection::get_strand() public. 2015-03-27 00:06:01 -04:00
Peter Thorson 6300e090ad disable emplace test
emplace requires move assignability which the class in question doesn’t
support.
2015-03-05 07:55:03 -06:00
Peter Thorson 45dfcbec3c changelog update 2015-03-04 18:43:49 -06:00
Peter Thorson 39dbe3a4e0 adds a vectored write handler for iostream transport 2015-03-04 18:42:55 -06:00
Peter Thorson 371d2cdaef Merge branch 'master' into permessage-deflate
Conflicts:
	websocketpp/version.hpp
2015-02-27 09:55:51 -05:00
Peter Thorson 13f6da6f81 fix typo in changelog entry about typos 2015-02-27 09:54:21 -05:00
Peter Thorson ac5d7ea5af changelog typo 2015-02-27 09:51:47 -05:00
Peter Thorson 6f7ecc59cd Bump patch version 2015-02-27 09:49:46 -05:00
Peter Thorson f7cea42c92 Fix a type in the name of the set method for max_http_body_size. fixes #406 2015-02-27 09:48:28 -05:00
Peter Thorson 9efb12e59b Fixes an issue where some frame data was counted against the max header size limit
End result was that connections that included a lot of frame data
immediately after the initial handshake would erroneously fail due to
hitting the max header size limit.
2015-02-27 09:48:00 -05:00
Peter Thorson 174698f1df update testee_server and testee_client Autobahn test examples to support permessage deflate 2015-02-27 07:48:45 -05:00
Peter Thorson 214cedf949 Update version info for permessage deflate branch 2015-02-27 07:48:08 -05:00
Peter Thorson c39412ee38 Update connection to negotiate extensions for clients 2015-02-27 07:47:31 -05:00
Peter Thorson 643e7a0ce1 Update processor to allow client side extension negotiation
Existing code worked for both client and server but the type signatures
needed some adjustment
2015-02-27 07:46:57 -05:00
Peter Thorson 349717ad46 set default extension offer string
Currently the offer is for default settings and advertises the ability
to accept any counteroffer.
2015-02-27 07:45:39 -05:00
Peter Thorson bcd82bd6f4 asio transport clients will now connect properly to servers using TLS SNI 2015-02-23 09:10:23 -05:00
Peter Thorson 8f042d95ec don't test for std::move on non-c++11 systems 2015-02-06 08:07:42 -05:00
Peter Thorson 0278ba7895 temporary disable of a unit test 2015-02-06 08:00:36 -05:00
Peter Thorson 41c37cfd93 make sure key is always initialized
some compilers complain without this. Its probably a safer sane default
anyways.
2015-02-06 07:58:00 -05:00
Peter Thorson 4bea90f555 preliminary support for move semantics for endpoints 2015-02-06 07:51:24 -05:00
Peter Thorson f9b08ccea1 Merge branch 'master' into permessage-deflate
Conflicts:
	websocketpp/extensions/permessage_deflate/enabled.hpp
2015-01-22 10:21:11 -05:00
Peter Thorson ce0300e6dc prepare develop branch for next version 2015-01-22 10:00:51 -05:00
Peter Thorson f20b2e573f Merge branch 'develop' 2015-01-22 09:56:40 -05:00
Peter Thorson 650e4c336b Prepare version 0.5.0 for submission 2015-01-22 09:56:20 -05:00
Peter Thorson 31c761a0a9 Endpoints are now reset after listen failure. fixes #390 2015-01-22 08:20:13 -05:00
Peter Thorson 681c2331a1 Fixes out of scope pointer returned from websocketpp::exception::what(); fixes #397
Also adds unit tests for exception construction
2015-01-22 07:33:14 -05:00
Peter Thorson fccc78479e retest 2015-01-20 08:29:02 -05:00
Peter Thorson 3017a9c5e4 increase test timeouts 2015-01-20 07:55:42 -05:00
Peter Thorson d55f28fe4b fix a bunch of minor warnings 2015-01-20 07:53:53 -05:00
Peter Thorson a8d4a9a66a increase test timeouts to help avoid false positives 2015-01-20 07:17:29 -05:00
Peter Thorson 17544d4d62 correct some documentation & fix warnings 2015-01-20 07:00:43 -05:00
Peter Thorson 4d1693c96c Merge branch 'master' into permessage-deflate
Conflicts:
	examples/print_server/print_server.cpp
	websocketpp/extensions/permessage_deflate/enabled.hpp
2015-01-20 06:51:06 -05:00
Peter Thorson 875d420952 Merge pull request #398 from rec/uninitialized-variable
Initialize websocketpp::transport::asio::endpoint::m_io_service to NULL.
2015-01-15 20:09:21 -06:00
Tom Ritchford d792639c20 Initialize websocketpp::transport::asio::endpoint::m_io_service to NULL. 2015-01-15 11:00:04 -05:00
Peter Thorson d4e15c89ad update changelog 2015-01-14 06:18:56 -06:00
Peter Thorson 1d29d48bb8 Merge pull request #393 from Schebb/develop
fixed 'localtime_*' compilation error MinGW
2015-01-14 06:12:58 -06:00
Peter Thorson 09c5f6505e Disable default use of C++11 threads on MinGW 2015-01-06 17:34:00 -06:00
Peter Thorson 745ed4f77a increase test timeout to help fail less on slow travis machines 2015-01-06 17:33:01 -06:00
Schebb 854166364b fixed 'localtime_*' compilation error MinGW 2015-01-06 13:23:53 +01:00
Peter Thorson 1517d646f9 update changelog, remove unused parameters 2014-12-16 07:05:47 -05:00
Peter Thorson 6bb36a28e7 typos 2014-12-16 06:38:37 -05:00
Peter Thorson 96362774a3 move this up a bit to ignore response status code 2014-12-16 06:36:34 -05:00
Peter Thorson 0a879a6dc2 add a check to gracefully exit if terminate was called during an http handler 2014-12-16 06:25:58 -05:00
Peter Thorson 867b323af0 add raw_head to http_request 2014-12-16 06:24:29 -05:00
Peter Thorson 9dd99ead25 gitignore debug stuff 2014-12-13 06:42:48 -05:00
Peter Thorson e3884e351b gitignore test 2014-12-13 06:41:12 -05:00
Peter Thorson 23e97bcc11 Better C++11 detection for visual studio 2014-12-13 06:24:52 -05:00
Peter Thorson 77e2e2fabb fix minor errors in debug transport 2014-12-13 05:55:31 -05:00
Peter Thorson ef393f8aef Overhaul error handling for failed WebSocket and HTTP connections 2014-12-12 18:31:21 -05:00
Peter Thorson 99f4a66221 Add processor error code for short hybi00 key3 reads 2014-12-12 18:08:05 -05:00
Peter Thorson 768472c0d4 get_websocket_version now checks if request is complete
an incomplete request otherwise would produce a spurious zero value
2014-12-12 18:07:32 -05:00
Peter Thorson 1f061a920e Changelog update 2014-12-12 06:59:53 -05:00
Peter Thorson 07543a5dde disable debugging output from tests 2014-12-11 10:29:41 -05:00
Peter Thorson ff9af5f8ca update gitignore to not ignore new debug code 2014-12-11 10:12:10 -05:00
Peter Thorson ffedb97372 move debug transport to non-relative path location 2014-12-11 10:09:28 -05:00
Peter Thorson e1f1c8873b Major overhaul to handshake internal state machine error checking references #389 #361
This overhaul removes the use of exceptions in handling state errors
during handshake processing. All such errors are demoted to
rerror/recoverable error and will terminate the connection only rather
than the whole application. In addition, there are some cases where we
expect to see a state error due to non-deterministic interleaving of
timeout handlers and read/write handlers. In these expected cases state
errors are ignored entirely.
2014-12-11 09:52:03 -05:00
Peter Thorson 922f1c35bc add testing system for timer/handshake handler interleaving
This interleaving is non-deterministic and pre-0.5 can result in state
errors when timer handers race with read/write handlers. These tests
explicitly and deterministically check all common interleaving for both
clients and servers.
2014-12-11 09:43:01 -05:00
Peter Thorson 3c6c757d93 debug client/server updates 2014-12-10 21:33:59 -05:00
Peter Thorson 71f88c71d6 better C++11 detection 2014-12-10 21:33:04 -05:00
Peter Thorson 987f20feda typos and fixes for stub config and minimal config 2014-12-10 21:28:18 -05:00
Peter Thorson 27cea4e58f don't set non-existent handler! 2014-12-08 19:35:47 -05:00
Peter Thorson e7b2e69ecb remove unneeded code 2014-12-08 19:26:24 -05:00
Peter Thorson bc868a244d queue for retest 2014-12-08 19:24:10 -05:00
Peter Thorson 77f1bf593d Adds telemetry_server example 2014-12-08 18:56:44 -05:00
Peter Thorson 0a47a9a78c adjust example exception behavior to match latest spec 2014-12-08 18:56:28 -05:00
Peter Thorson 6578c5852e Add Hybi proposed generic subprotocol errors 2014-12-05 21:02:33 -05:00
Peter Thorson f9ff42c4b0 update boundaries checking code to be slightly tigher 2014-12-05 21:02:33 -05:00
Peter Thorson b9d4187e38 logger documentation 2014-12-05 10:19:31 -05:00
Peter Thorson cbe887524e Documentation and code style for syslog logger references #386 2014-12-05 10:10:44 -05:00
Peter Thorson 8a9b0beec0 Merge pull request #386 from airtimemedia/syslog
Add syslog logger support.
2014-12-05 09:20:41 -05:00
Peter Thorson 18994f7318 Add write_handler to iostream as an ostream replacement 2014-12-04 09:12:57 -05:00
Peter Thorson 3f65b2ff98 changelog update 2014-12-04 08:19:16 -05:00
Peter Thorson 0ad2da2083 updates to debug server to help test HTTP request body issues 2014-12-04 08:16:32 -05:00
Peter Thorson 7404b506db Add shutdown handler to iostream transport references #388 2014-12-04 08:15:57 -05:00
Tom Hughes b0efc72848 Remove virtual methods from syslog implementation. 2014-12-02 10:06:28 -08:00
Tom Hughes beac6e5bb6 Add syslog logger support. 2014-11-26 14:14:09 -08:00
Peter Thorson f6c6552622 Access to HTTP request bodies references #181
Use connection::get_request_body() to access. Use
endpoint::set_max_http_body_size(size_t value) to control maximum
upload size. Initial support is for single chunk bodies that define a
content-length . Transfer-Encoding: chunked is not currently supported
2014-11-18 22:05:46 -05:00
Peter Thorson 12700f2bc2 implement HTTP request body parsing 2014-11-18 22:00:31 -05:00
Peter Thorson 8cbe22266d include cleanup 2014-11-18 21:58:47 -05:00
Peter Thorson c23639d394 const correctness 2014-11-18 21:58:17 -05:00
Peter Thorson d3ba1187de use C++ style c-library header 2014-11-18 08:18:20 -05:00
Peter Thorson 02b53d979e changelog update 2014-11-18 08:11:52 -05:00
Peter Thorson 1d598558d8 code style, correct more STL includes 2014-11-18 08:10:39 -05:00
Peter Thorson ff3009ed26 remove unused file 2014-11-18 07:53:27 -05:00
Peter Thorson d1f3eb9516 code style, correct STL includes 2014-11-18 07:52:36 -05:00
Peter Thorson c0dc3c0e5f add documentation, fix STL includes, remove deprecated HTTP parser methods 2014-11-18 07:25:45 -05:00
Peter Thorson bfbfe2b052 Clean up code style and STL includes 2014-11-18 07:13:34 -05:00
Peter Thorson 1edc8deb01 remove unnecessary include 2014-11-18 06:57:54 -05:00
Peter Thorson 571be82531 code style 2014-11-17 22:16:33 -05:00
Peter Thorson 9ab9941f5e remove unused type 2014-11-17 22:11:02 -05:00
Peter Thorson 7dfe0d5815 fix some utility client warnings 2014-11-15 13:02:29 -05:00
Peter Thorson 088625eb53 changelog typo 2014-11-15 12:55:53 -05:00
Peter Thorson 575834b534 utility_client tutorial updates 2014-11-15 12:52:19 -05:00
Peter Thorson 02dd5150fc Chapter 6 (sending/receiving message) of utility_client tutorial 2014-11-15 11:22:08 -05:00
Peter Thorson 2917d9262c share C++11 detection logic 2014-11-15 11:13:01 -05:00
Peter Thorson fbc2966cda Frame payload logging now prints text messages as text rather than binary 2014-11-14 09:31:53 -05:00
Peter Thorson 9de0a087b3 prepared messages now have correct opcode
This value is only used internally
2014-11-14 09:30:40 -05:00
Peter Thorson e9dd9cbbeb fix spelling error 2014-11-14 09:29:35 -05:00
Peter Thorson dc7431c37f http::request::raw should be const 2014-11-08 08:18:02 -05:00
Peter Thorson 5fe6f8338d Disable SSLv3 in example servers 2014-11-04 12:26:07 -05:00
Peter Thorson 19f7886ca4 reset dev branch versions to dev status 2014-11-04 12:23:30 -05:00
Peter Thorson 802e34bd2c Merge branch 'develop' 2014-11-04 07:35:10 -05:00
Peter Thorson 4100fc3ce7 normalize copyright dates and prep release version 2014-11-04 07:31:24 -05:00
Peter Thorson 6bda8f85d4 adjust C++11 cmake settings on windows 2014-11-04 06:52:44 -05:00
Peter Thorson 56cdbcd1da more gcc put_time debugging 2014-11-03 17:37:04 -05:00
Peter Thorson 4c15d27bf4 fixes an issue with signed/unsigned comparison 2014-11-03 14:39:34 -05:00
Peter Thorson b3b20ebb04 fix for non-threadsafe use of localtime fixes #347 2014-11-03 09:51:02 -05:00
Peter Thorson 397f5c00bf better fix for use of put_time
Put time can’t be activated by _WEBSOCKETPP_CPP11_STL_ due to backwards
compatibility issues with GCC 4.7 and 4.8 which otherwise work with
that define but do not support put_time
2014-11-03 09:48:43 -05:00
Peter Thorson 82502a651a run travis on develop branch 2014-11-03 08:59:29 -05:00
Peter Thorson b46c0fb142 adds std/boost::ref as needed for non-const references passed to make_shared
required for boost::make_shared to work without rvalue references.
2014-11-03 08:53:49 -05:00
Peter Thorson e1a0401d25 fixes guard macro for use of std::put_time
std::put_time is in the c++11 iomanip header not chrono
2014-11-02 19:12:16 -05:00
Peter Thorson f23abe8e70 Fix bug in chrono config by boost_config 2014-11-02 19:08:15 -05:00
Peter Thorson 4309749dd9 switch to alternate method of clearing function objects
may help with null_ptr related issues when using boost with c++11
compilers
2014-10-19 08:56:07 -04:00
Peter Thorson f06b623767 Merge pull request #379 from dnovikoff/develop
Using std/boost make_shared for creating shared pointers
2014-10-15 08:56:36 -04:00
Peter Thorson 9807283a6b Update sha1::calc length parameter to more sane type references #358
also cleans up formatting and code style and adds documentation
2014-10-14 22:17:57 -04:00
Peter Thorson 83a66f4e3f Update base64_encode length parameter to more sane type references #358
Also adds documentation and cleans up formatting
2014-10-14 08:28:26 -04:00
Peter Thorson 2e7a902ef7 prefix htonll/ntohll fixes #381 fixes #382 references #358
This avoids conflicts with OS level macros
2014-10-14 08:08:30 -04:00
Peter Thorson 55b6cfae90 Merge pull request #369 from codemercenary/gitignore
Updating ignore list for in-source MSVC CMake environments
2014-10-08 10:36:58 -04:00
Peter Thorson 95bfe7c5ba Merge pull request #377 from LocutusOfBorg/patch-2
Fix build failure if CMAKE_CXX_FLAGS is not empty
2014-10-08 10:31:09 -04:00
Dmitry Novikov f7aeeaaa30 Using std/boost make_shared for creating shared pointers
Fixed boost::function nulling issue
2014-10-08 16:11:46 +04:00
Gianfranco Costamagna 55827fc825 Fix build failure if CMAKE_CXX_FLAGS is not empty
The wrong " were adding a new parameter, leading to an expanded flag list like
"-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 ;-std=c++0x"
and an obvious
"g++-4.8.real: fatal error: no input files"
error message.
2014-10-08 10:05:59 +02:00
Peter Thorson d7a7112c8b removes unused qualifiers references #376 2014-10-07 10:17:02 -04:00
Peter Thorson d6c9905e80 fixes another shadowing warning 2014-10-07 10:16:28 -04:00
Peter Thorson 0e66dbfde4 lots of cleanup of unused code & parameters references #376 2014-10-07 10:11:37 -04:00
Peter Thorson e8d25d22bc adds documentation and removes unused parameters references #376 2014-10-07 10:04:54 -04:00
Peter Thorson fe6d82e7a3 fix local variable shadowing warning 2014-10-07 08:17:53 -04:00
Peter Thorson 2f64f8d91a adds documentation and removes unused parameters references #376 2014-10-06 19:04:04 -04:00
Peter Thorson 6da47743e8 removes unused function references #376 2014-10-06 18:34:13 -04:00
Peter Thorson 6c242b205b detab entire project references #376 2014-10-06 18:33:55 -04:00
codemercenary 2d2c62c887 Updating ignore list for in-source MSVC CMake environments 2014-08-20 11:35:35 -07:00
Peter Thorson 71a10d83c8 Merge core requirements feature branch 2014-08-09 16:18:00 -05:00
Peter Thorson fe0310b283 make version introduced notes less specific 2014-08-09 16:13:19 -05:00
Peter Thorson 8a7beaa86a Merge branch 'exception_refactor' into develop
Conflicts:
	changelog.md
	websocketpp/impl/connection_impl.hpp
2014-08-09 15:44:46 -05:00
Peter Thorson 5d0c2f6341 update version information for develop branch 2014-08-09 15:38:25 -05:00
Peter Thorson 122d4e2128 Reduce conflict between std::min and macros
Adjust usage of std::min to be more compatible with systems that define
a min(...) macro
2014-08-09 15:36:10 -05:00
Peter Thorson e203dbed45 package for 0.3.0 release 2014-08-09 14:06:22 -05:00
Peter Thorson ad2932bbff Disable open timeout when duration is set to zero 2014-07-24 21:39:12 -05:00
Peter Thorson 3560fa144a Merge pull request #359 from redboltz/add_semicolon
Added a semicolon.
2014-07-08 18:56:42 -05:00
Takatoshi Kondo 296f61b595 Added a semicolon. 2014-07-08 17:15:19 +09:00
Peter Thorson 65cc3765a8 add docs for namespaces and concurrency policies 2014-05-30 16:02:07 -05:00
Peter Thorson 10be5eee14 clarified documentation for bad_connection error 2014-05-30 16:02:07 -05:00
Peter Thorson c39777e4c1 add documentation for socket policies 2014-05-30 16:02:06 -05:00
Peter Thorson af7149ae0a Adds read_all method to iostream transport
Adds `connection::read_all(...)` method to iostream transport as a
convenience method for reading all data into the connection buffer
without the end user needing to manually loop on `read_some`.
2014-05-22 21:10:58 -05:00
Peter Thorson 7c3eb3e6c2 fix log wording 2014-05-22 21:10:57 -05:00
Peter Thorson e7ce038207 remove unused file 2014-04-10 10:53:41 -05:00
Peter Thorson aaed2c4950 fix whitespace 2014-04-10 10:20:26 -05:00
Peter Thorson 64fffeda9f Add combination plain+TLS echo example 2014-04-10 10:19:30 -05:00
Peter Thorson 7137105a81 documentation updates 2014-04-02 11:57:04 -05:00
Peter Thorson beaa6e98cc testee server defaults changes 2014-03-27 07:43:36 -05:00
Peter Thorson 79c2d09200 remove debug logging from critical paths 2014-03-27 07:43:11 -05:00
Peter Thorson c021766592 these are not defined in RFC6455 2014-03-26 07:29:27 -05:00
Peter Thorson 7f7e9d2c2c update interface and unit tests for new permessage-deflate parameter names 2014-03-26 07:19:35 -05:00
Peter Thorson 70923eea23 remove raw cout debug code 2014-03-26 06:48:36 -05:00
Peter Thorson 99ae2f768c fix issue where fragmented messages weren't getting decompressed correctly
the rsv1 bit is only set for the first fragment. check it then and
store the result in the message’s compressed flag instead.
2014-03-26 06:48:26 -05:00
Peter Thorson 884e7d210c this is just wrong, removing 2014-03-26 06:47:28 -05:00
Peter Thorson 75dd6f3ba5 fix negotiating multiple copies of the same extension 2014-03-25 19:43:11 -05:00
Peter Thorson 2ee496c08d update parameter fields to latest draft 2014-03-25 19:35:24 -05:00
Peter Thorson aabf87b6b1 add missing tls libraries 2014-03-25 19:35:07 -05:00
Peter Thorson cfabe17e83 Merge branch 'master' into permessage-deflate
Conflicts:
	changelog.md
2014-03-25 19:16:19 -05:00
Peter Thorson b92a2b7f61 Merge branch 'master' into exception_refactor 2014-03-25 07:22:54 -05:00
Peter Thorson 1f73456e25 update changelog 2014-03-25 07:22:40 -05:00
Peter Thorson 0ca2bae121 Merge branch 'master' into core_dependencies
Conflicts:
	changelog.md
2014-03-25 07:17:12 -05:00
Peter Thorson 002d2d0007 force the offset to be calculated first to avoid confusing MSVC's checked iterators references #342
Thank you tmoers for reporting
2014-03-25 06:15:40 -05:00
Peter Thorson d8b7cf3fdc Merge pull request #343 from zaphoyd/batched_send
Batched send
2014-03-25 06:03:23 -05:00
Peter Thorson b358e2cfe8 update changelog 2014-03-25 05:49:15 -05:00
Peter Thorson 099fdbd4f1 Merge branch 'master' into batched_send 2014-03-25 05:46:12 -05:00
Peter Thorson 19a3713b29 use libc++ for non-c++11 branches on mac os x 2014-03-24 08:07:40 -05:00
Peter Thorson cd534ad18e implements batch sending
rather than writing a single message per trip through the underlying
transport, writes are batched and sent as a group. This drastically
improves the system call / application code ratio and tcp packet
utilization rates when sending lots of small messages
2014-03-24 08:04:23 -05:00
Peter Thorson 7a46203beb added a note about breaking changes in the logging policy API 2014-03-20 07:18:59 -05:00
Peter Thorson 497bc574da remove references to unused iostream header from asio transport 2014-03-20 07:15:02 -05:00
Peter Thorson 0bfb67ef11 Add minimal_client and minimal_server configs references #338 2014-03-20 07:03:31 -05:00
Peter Thorson 762c013b93 Adds a stub transport policy
This will be used in the minimal config to avoid bringing in iostream
dependencies. It will also be used to document the minimal interface
for writing a custom transport policy.
2014-03-20 07:02:40 -05:00
Peter Thorson 9d237effc7 remove dependency on std::iostream from core
It is still required for the iostream transport and the basic
(iostream) logging policy.
2014-03-20 06:10:24 -05:00
Peter Thorson e2b7a4b9f1 fix whitespace 2014-03-16 09:59:34 -05:00
Peter Thorson e154d955ec Use __cplusplus header to enable C++11 language features 2014-03-16 09:26:51 -05:00
Peter Thorson 2207348abb Merge pull request #340 from dschmidt/master
Use _WIN32 instead of WIN32 preprocessor directive
2014-03-16 09:09:14 -05:00
Dominik Schmidt 77495d4076 Use _WIN32 instead of WIN32 preprocessor directive and fix warnings 2014-03-14 17:42:05 +01:00
Peter Thorson 8752687bc8 Merge pull request #339 from jefferai/master
Add define to allow disabling threading entirely
2014-03-12 13:15:24 -05:00
Jeff Mitchell 0f3a36a630 Add define to allow disabling threading entirely, for when using an
iostream-based client.
2014-03-12 10:46:33 -04:00
Peter Thorson a63f7d8b7b switch all exceptions to be of type websocketpp::exception 2014-03-06 19:35:25 -06:00
Peter Thorson edb26d7721 listen errors are now reported to the caller 2014-03-06 19:01:11 -06:00
Peter Thorson b2d698d3ca include hdl in message actions
This is not strictly necessary for the broadcast server example. As
this example is commonly used as a starting point for new programs the
lack of hdl on message action is a source of surprising behavior.
2014-03-06 11:59:38 -06:00
Peter Thorson 770b32275c updates websocketpp::exception to wrap lib::error_code 2014-03-05 08:30:08 -06:00
Peter Thorson 9d8eced9a1 Refactored server_endpoint to allow end users to access start_accept error states references #335
also more documentation
2014-03-05 08:06:14 -06:00
Peter Thorson fd0c62a8e4 add TLS config and types to asio integration tests 2014-03-05 07:27:41 -06:00
Peter Thorson 1a68f4b907 Merge pull request #335 from aydany/master
Require a valid con before calling terminate
2014-03-05 07:23:19 -06:00
Aydan Yumerefendi c3dfb25181 Merge remote-tracking branch 'upstream/master'
Conflicts:
	websocketpp/roles/server_endpoint.hpp
2014-03-04 21:19:24 -05:00
Aydan Yumerefendi 5a5d8321bd Require a valid con before calling terminate
If get_connection returns null, e.g., if during stop the tls_init
handler is removed from the server, con->terminate will cause a crash.
2014-03-04 21:02:42 -05:00
Peter Thorson b805689f9c whitespace and don't accept if we know the transport isn't listening references #334 2014-03-04 06:45:00 -06:00
Peter Thorson 7eedf25500 Merge pull request #334 from aydany/master
Avoid leak when stopping server
2014-03-04 06:18:34 -06:00
Aydan Yumerefendi 3ca53d0064 Avoid leak when stopping server
If accept fails, e.g., because the server is no longer listening the
connection object is not terminated and it results in a memory leak:
connection -> handler -> connection.
2014-03-03 21:51:56 -05:00
Peter Thorson 5e2fadd826 pass better information about TLS handshake failures 2014-03-03 17:09:55 -06:00
Peter Thorson 840bb6b59e code style and whitespace 2014-03-03 10:32:04 -06:00
Peter Thorson fe00a84f7b Merge pull request #333 from aydany/master
Fix memory leak when init_asio fails
2014-03-03 10:24:11 -06:00
Aydan Yumerefendi 337bf2fb0a Fix memory leak on create
If the socket fails to initialize, e.g., by omitting the tis init
handler, the connection is leaked, since there is a circular reference
between the connection and its async_read/async_write handlers. To fix
this, check the error code, and reset the handler is an error has
occurred.
2014-03-03 11:08:24 -05:00
Peter Thorson c5b5492e5c fix memory leak when a connection fails references #323 2014-03-02 22:12:38 -06:00
Peter Thorson af15537205 add debug header to integration tests 2014-03-02 22:12:14 -06:00
Peter Thorson bdeb4ad680 code style and documentation 2014-03-02 21:39:34 -06:00
Peter Thorson faad2ec854 add copyright info to debug client 2014-03-02 19:43:25 -06:00
Peter Thorson dc06049df9 add debug server example 2014-03-02 19:43:11 -06:00
Peter Thorson 3e53c74c3f Merge pull request #332 from zaphoyd/tutorials
Update examples and tutorials
2014-03-02 19:27:56 -06:00
Peter Thorson a5a30e554e rename app_client to utility_client and set utility_client to be the final step of the utility_client tutorial 2014-03-02 19:21:17 -06:00
Peter Thorson 9c8762c961 rename old utility client to debug client 2014-03-02 19:20:42 -06:00
Peter Thorson 797ce35c5a more renaming and adding license notes 2014-03-02 19:14:59 -06:00
Peter Thorson 30da3a967b renaming and re-titling the app client tutorial to utility client 2014-03-02 19:10:24 -06:00
Peter Thorson e1547bbde8 stray characters 2014-03-02 19:04:13 -06:00
Peter Thorson 37f69cc19b fix typo 2014-03-02 19:03:04 -06:00
Peter Thorson 93d9b5f820 Formatting fixes for app client tutorial step 5 2014-03-02 19:02:11 -06:00
Peter Thorson 98fd183210 Finish app client tutorial step 5 (closing) 2014-03-02 18:53:55 -06:00
Peter Thorson 093806f860 Merge branch 'master' into tutorials 2014-03-02 12:21:32 -06:00
Peter Thorson 1da45144e9 whitespace 2014-03-02 12:21:04 -06:00
Peter Thorson 5f56976290 Add method to look up a human readable string given a close code value 2014-03-02 12:19:50 -06:00
Peter Thorson 40ed74a141 Use clang on OS X by default for building examples and tests 2014-03-02 12:17:03 -06:00
Peter Thorson fbc9db2b5d work on close step 2014-03-02 12:06:37 -06:00
Peter Thorson f87c9d4360 need the line breaks to work here 2014-03-02 08:33:41 -06:00
Peter Thorson 99461184d3 Merge pull request #331 from zaphoyd/tls_short_read
Tls short read related changes references #263
2014-02-28 09:04:59 -06:00
Peter Thorson 9eff0db756 update changelog 2014-02-28 09:05:53 -06:00
Peter Thorson 86325b1838 cleans up the handling of TLS related transport errors
Specifically: TLS short read is separated from other TLS errors. Other
TLS errors are also not separated from generic “pass through” errors.

TLS short read is now considered “expected” during socket shutdown and
is not reported as an error.
2014-02-28 09:02:26 -06:00
Peter Thorson 2d2312a1d7 add socket/security policies to translate asio -> websocketpp error codes
The reason these were added to the socket policies rather than higher
up is that in some cases translating error codes requires information
from headers and libraries that are not present except when certain
socket policies are being used. For example, SSL/TLS related errors can
only be translated using openssl, which is only pulled in with the TLS
socket policy.
2014-02-28 09:00:45 -06:00
Peter Thorson afc28be004 whitespace 2014-02-28 08:27:29 -06:00
Peter Thorson b7c5a2e791 tls short read in state closed is no longer an error 2014-02-28 08:27:14 -06:00
Peter Thorson d36925ce7d Add new generic TLS error code 2014-02-28 08:26:50 -06:00
Peter Thorson 92dfe9ef97 clarify commands section and new members/methods of websocket_endpoint 2014-02-23 15:46:51 -06:00
Peter Thorson 2ab02197fd Fleshes out step 4 (opening connections) 2014-02-23 15:31:54 -06:00
Peter Thorson 89ac45e60a additional work on app client tutorial 2014-02-23 09:34:34 -06:00
Peter Thorson 713a05679c Merge pull request #325 from zaphoyd/max-message-size
error handling changes that ended up on wrong branch
2014-02-18 07:59:20 -06:00
Peter Thorson 0fecf023ef refactor connection error handling code 2014-02-18 08:01:16 -06:00
Peter Thorson ffdf5f842b reclassify action after shutdown as info rather than fatal references #62 2014-02-18 07:59:43 -06:00
Peter Thorson d425caea80 Fix misclassified error log entry 2014-02-18 07:58:49 -06:00
Peter Thorson ce2c1d6e34 whitespace 2014-02-13 11:18:44 -06:00
Peter Thorson 7ceeaa4f9c fix documentation spelling error 2014-02-13 11:10:47 -06:00
Peter Thorson 883410bb77 Fix an issue where custom timeout values weren't being propagated from endpoints to new connections 2014-02-12 15:07:09 -06:00
Peter Thorson 724974c758 Merge pull request #322 from zaphoyd/max-message-size
Adds the ability to specify a max message size
2014-02-10 20:55:02 -06:00
Peter Thorson 1622cdde04 Retry the travis build 2014-02-10 20:51:37 -06:00
Peter Thorson 180543b9e6 Adds the ability to specify a maximum message size 2014-02-10 09:21:07 -06:00
Peter Thorson 7c08cae15b fix bug that caused all error close frames to have a blank code 2014-02-10 09:17:43 -06:00
Peter Thorson 81e0c44b34 update debug config with max_message_size constant 2014-02-10 09:16:47 -06:00
Peter Thorson 722a67a910 add message payload size reservation 2014-02-10 08:39:20 -06:00
Peter Thorson ba6320ba1c Add maximum message size functionality to processors 2014-02-10 08:38:54 -06:00
Peter Thorson d9aa498310 whitespace cleanup 2014-02-10 08:37:47 -06:00
Peter Thorson 47c46a2fbc Fleshes out the remainder of app tutorial step 3 2014-02-07 08:10:10 -06:00
Peter Thorson 9401cf00ce rework app tutorial step 2 2014-02-07 07:26:00 -06:00
Peter Thorson acedd4db49 tutorial formatting 2014-02-07 06:59:28 -06:00
Peter Thorson 91617150e1 more tutorial formatting tests 2014-02-07 06:56:48 -06:00
Peter Thorson c7463afb06 tutorial updates 2014-02-07 06:49:45 -06:00
Peter Thorson ba90910f6e Fix an issue where set_open_handshake_timeout was ignored for servers 2014-02-05 21:00:30 -06:00
Peter Thorson bee2c03aa0 code style updates 2014-02-05 20:56:54 -06:00
Peter Thorson 8e86ddcf5a fix typos in comments 2014-02-02 19:28:23 -06:00
Peter Thorson fe85de763e Adds configurable SO_REUSEADDR option. references #311 2014-02-02 18:12:30 -06:00
Peter Thorson ca97dd1fb8 Switch to c-based tolower rather than c++ to avoid confusing Visual Studio references #287 2014-02-02 17:04:50 -06:00
Peter Thorson c7ec97795a add C++11 nullptr support detection 2014-02-02 17:03:41 -06:00
Peter Thorson 6ee7c368bb remove unused variables 2014-02-02 15:14:12 -06:00
Peter Thorson 2000746be7 correct misc minor warnings 2014-02-02 15:12:42 -06:00
Peter Thorson c84cc110aa Corrects more obscure shadowed variable cases 2 2014-02-02 13:17:17 -06:00
Peter Thorson 09940a5c0b Corrects more obscure shadowed variables cases 2014-02-02 13:12:52 -06:00
Peter Thorson bb21e3cf95 Fix use of variable names that shadow function parameters. references #318 2014-02-02 11:10:39 -06:00
Peter Thorson 5f3b92c9e4 Fix compile time conflict with Visual Studio's MIN/MAX macros. 2014-02-02 10:58:02 -06:00
Peter Thorson 14074666a7 disable some debugging output 2014-02-02 10:55:31 -06:00
Peter Thorson bb431ee0d2 Fix a crash following use of the stop_listening function. 2014-01-26 20:53:17 -06:00
Peter Thorson 373f180638 re-classify some errors with more specific codes and more appropriate logging levels 2014-01-26 20:50:31 -06:00
Peter Thorson 021ac0599c add additional error codes 2014-01-26 20:49:20 -06:00
Peter Thorson e44463583b Fix a crash when parsing empty HTTP headers 2014-01-26 19:39:55 -06:00
Peter Thorson 4393a2562b Add the ability to pause reading on a connection 2014-01-25 18:46:44 -06:00
Peter Thorson 780f7683a4 add typedefs for iostream clients and servers to integration test suite 2014-01-25 18:29:54 -06:00
Peter Thorson 8f359e6d35 typo 2013-12-14 09:37:16 -06:00
Peter Thorson ebb65c81e2 Allow disabling open, close, and pong timers entirely
Set their duration to zero to do this
2013-12-14 09:31:58 -06:00
Peter Thorson c7fda5a960 remove debug output from test 2013-12-14 09:31:58 -06:00
Peter Thorson 6d4514246f separate step 2 and 3 2013-12-14 07:41:21 -06:00
Peter Thorson c2f2cb951b Fixes some calls to empty lib::functions, references #310 2013-12-10 22:02:22 -06:00
Peter Thorson 827f3678bb Fixes a leak of connection objects when using asio transport references #310 2013-11-26 22:05:26 -06:00
Peter Thorson 57cd0e286e roadmap / wishlist for broadcast tutorial 2013-11-25 08:20:52 -06:00
Peter Thorson 87cb5036a4 initial work on app client tutorial 2013-11-25 08:16:14 -06:00
Peter Thorson f05f18b384 clean up chat tutorial a bit 2013-11-25 08:15:20 -06:00
Peter Thorson 01963a23ea working copy of app client tutorial example 2013-11-21 20:17:39 -06:00
Peter Thorson 18036d2b01 sets mutex to mutable to allow use in const accessors references #292 2013-11-05 07:52:31 -06:00
Peter Thorson 17bd89bd80 code style 2013-11-05 07:50:20 -06:00
Peter Thorson f59f301b91 fix typo in testee server 2013-11-04 17:36:55 -06:00
Peter Thorson 319507f4af update testee_server to disable nagle algorithm 2013-11-04 16:50:45 -06:00
Peter Thorson 06cdf43dcf Add start_perpetual and stop_perpetual to asio transport
These may be used to replace manually managed `asio::io_service::work`
objects
2013-11-04 16:50:35 -06:00
Peter Thorson f8f945433f code style 2013-11-04 07:40:11 -06:00
Peter Thorson a4f96cf0c3 groundwork for unclean close options 2013-11-04 07:40:06 -06:00
Peter Thorson 7032e6940f adds tcp pre and post init setting functionality to endpoint 2013-11-03 13:32:17 -06:00
Peter Thorson bfd50e1ee1 locks and spacing 2013-11-03 13:25:21 -06:00
Peter Thorson 415533f7e7 labels changes feature vs bug 2013-11-03 12:44:28 -06:00
Peter Thorson b87bfc068e Allow setting pong and handshake timeouts at runtime 2013-11-03 12:40:55 -06:00
Peter Thorson dbb5f963c8 update testee server to use extended listen backlog 2013-11-03 12:31:54 -06:00
Peter Thorson a1872c3790 Merge branch 'master' of https://github.com/zaphoyd/websocketpp
Conflicts:
	changelog.md
2013-11-02 19:34:01 -05:00
Peter Thorson 8993b34b3d Allows changing the listen backlog queue length 2013-11-02 19:32:38 -05:00
Peter Thorson 7ae83b9efd update changelog 2013-11-02 18:25:55 -05:00
Peter Thorson 430c49d394 splits tcp init into pre and post init 2013-11-02 18:25:21 -05:00
Peter Thorson 3e5404e1b1 split handler allocator into separate one for reads and writes 2013-11-02 18:24:14 -05:00
Peter Thorson 8524a1a272 add program arguments 2013-11-02 18:22:58 -05:00
Peter Thorson 6f79894ea5 add variable port and thread count to testee server 2013-11-02 17:59:55 -05:00
Peter Thorson 5e803b57f7 add uri unit test 2013-11-01 16:05:46 -05:00
Peter Thorson 6a3e886f0b update HTTP parser tests to use more specific test checks 2013-10-25 07:23:30 -05:00
Peter Thorson ac9351f9b3 strips LWS from incoming headers per RFC2616. fixes #301 2013-10-25 07:23:06 -05:00
Peter Thorson 00b5bed0d1 moves base64 code into websocketpp namespace 2013-10-20 15:02:51 -05:00
Peter Thorson 0f6e93a13e removes original copies of header-converted libraries to avoid confusion 2013-10-20 15:02:29 -05:00
Peter Thorson 84efd0425a moves sleep call out of a critical section references #283 2013-10-20 14:44:37 -05:00
Peter Thorson f4d3640870 update changelog 2013-10-20 14:30:54 -05:00
Peter Thorson 6680606523 Merge pull request #297 from evgeni/master
fix "recieve" typo in various places
2013-10-20 12:17:58 -07:00
Peter Thorson 962a090300 update code style and add docs+tests for uri::get_query references #298 2013-10-20 14:15:05 -05:00
Peter Thorson 4d51d990a4 Merge pull request #298 from Banaan/master
add get_query to URI handling
2013-10-20 12:00:54 -07:00
Peter Thorson 362f828767 update changelog 2013-10-20 13:14:12 -05:00
Peter Thorson aa74d2b295 switched asio read and write handler to use a custom allocator 2013-10-20 13:09:37 -05:00
Peter Thorson 746389efab removes some range checking in an inner read loop 2013-10-20 13:05:46 -05:00
Peter Thorson 5894601291 caches callback functions rather than copying them from handler to handler 2013-10-20 13:03:32 -05:00
Peter Thorson 17c9831449 cache the binding of async read and write handler callbacks 2013-10-20 12:57:02 -05:00
Peter Thorson 45a612f44b additional support for compile time disabling of multithreading features 2013-10-20 12:54:59 -05:00
Peter Thorson 2e3dfe7935 disable boundary checking in inner read loop 2013-10-20 12:50:10 -05:00
Peter Thorson 1b453e4679 adjust default read buffer size based on profiling 2013-10-20 12:49:22 -05:00
Peter Thorson 72a3bd6e4e add custom config to testee server to allow easier tuning 2013-10-20 12:48:09 -05:00
Banaan e73f4cdb10 Update uri.hpp
get query of URI method
2013-10-20 19:35:47 +02:00
Evgeni Golov 86fe22334c fix "recieve" typo in various places 2013-10-20 17:19:26 +02:00
Peter Thorson 71e6babd93 statically bind frame read and write handlers 2013-10-16 08:25:10 -05:00
Peter Thorson 8b9fa5db72 add switchable 1 vs 2 thread testee server operation 2013-10-16 08:24:28 -05:00
Peter Thorson 57d8e5cb6b add better clarification to exception printing 2013-10-16 08:24:02 -05:00
Peter Thorson 1e97f6c67c statically bind the async_read_handler 2013-10-16 08:23:42 -05:00
Peter Thorson 5c14c8e71e adds a compile time multithreading switch 2013-10-16 08:22:14 -05:00
Peter Thorson e62823a0af update deflate constants 2013-10-16 06:29:46 -05:00
Peter Thorson 933533c623 initial notes about tutorials 2013-10-13 12:49:30 -05:00
Peter Thorson 4231edec53 package as alpha4 2013-10-11 06:39:55 -05:00
Peter Thorson 4761938600 bugfix 2013-10-10 14:05:09 -05:00
Peter Thorson bf5f2852f9 updates license information for UTF8 validation logic references #294 2013-10-10 14:00:10 -05:00
Peter Thorson e16972b153 HTTP requests ending normally are no longer logged as errors. references #294 2013-10-10 13:47:01 -05:00
Peter Thorson 3d0d28affc Eliminate spurious expired timers in certain error conditions references #295 2013-10-10 13:45:49 -05:00
Peter Thorson 63cdaec0ba removes unused variable set per static analysis 2013-10-10 13:14:06 -05:00
Peter Thorson 43a258efaa updates changelog 2013-10-10 08:42:13 -05:00
Peter Thorson 3d57d412f7 Updates COPYING file to include all bundled licenses references #294 2013-10-10 08:20:03 -05:00
Peter Thorson 97e5e5fc7b replaces sha1 library with a more clearly licensed project references #294 2013-10-10 08:19:43 -05:00
Peter Thorson ed39a6ab1a Re-introduces strands to asio transport 2013-10-06 14:58:29 -05:00
Peter Thorson 67804061ea update changelog 2013-10-06 11:02:29 -05:00
Peter Thorson b934e71ace adjust transport async_accept and async_connect to use connection_ptr instead of connection_hdl
prevents a newly created connection_ptr from being destroyed
immediately after accepting or connecting.
2013-10-06 10:51:41 -05:00
Peter Thorson 96f7d0f3f2 catch test error condition better 2013-10-06 10:48:23 -05:00
Peter Thorson 013c2da7e8 removes internal connection tracking mechanism from endpoint 2013-10-06 10:47:59 -05:00
Peter Thorson aebdb26dc6 additional debug log detail 2013-10-06 10:34:15 -05:00
Peter Thorson 550365df6a updates iostream tests for new safer/less leaky API 2013-09-28 07:57:38 -05:00
Peter Thorson e91d6f6a45 refactor iostream read completion to remove memory leak 2013-09-28 07:56:41 -05:00
Peter Thorson de6d15c9fc adds documentation notes about when fatal_error and eof methods showed up 2013-09-28 07:56:03 -05:00
Peter Thorson 3035c8dc0a Deprecates iostream transport readsome in favor of read_some
which is more consistent with the naming of the rest of the library.
2013-09-28 07:55:41 -05:00
Peter Thorson c175ec4f42 Adds preliminary signaling to iostream transport of eof and fatal transport errors 2013-09-27 21:24:33 -05:00
Peter Thorson e6319f51a4 Updates transport code to use shared rather than raw pointers. references #293 2013-09-26 07:43:10 -05:00
Peter Thorson d17569fa87 fixes issue where custom headers couldn't be set for client connections 2013-09-25 08:18:46 -05:00
Peter Thorson 8ce05cd228 Merge branch 'master' into permessage-deflate
Conflicts:
	test/extension/permessage_deflate.cpp
	websocketpp/extensions/permessage_deflate/disabled.hpp
	websocketpp/extensions/permessage_deflate/enabled.hpp
	websocketpp/impl/connection_impl.hpp
	websocketpp/message_buffer/message.hpp
	websocketpp/processors/hybi13.hpp
2013-09-08 13:39:17 -05:00
Peter Thorson f22c542a0d update credits for previous fix 2013-08-30 16:34:54 -05:00
Peter Thorson e9cb0b840f fixes a compile error on visual studio when using interrupts 2013-08-30 15:52:26 -05:00
Peter Thorson bd9c9767e1 Updates message buffer documentation and style 2013-08-17 12:16:21 -05:00
Peter Thorson 80133d6d55 fix unit tests 2013-08-15 08:37:29 -05:00
Peter Thorson ac41f467ed Merge branch 'master' of https://github.com/zaphoyd/websocketpp
Conflicts:
	changelog.md
2013-08-15 07:46:48 -05:00
Peter Thorson cab72215aa adds new close codes per IANA registry 2013-08-15 07:46:07 -05:00
Peter Thorson 12d240ff09 fix typo 2013-08-12 11:25:12 -05:00
Peter Thorson 107d3c9bb6 add set_remote_endpoint method to iostream transport 2013-08-12 11:22:45 -05:00
Peter Thorson 49c07296dd iostream transport documentation 2013-08-12 11:22:26 -05:00
Peter Thorson 8475f5f200 add iostream transport set_secure functionality 2013-08-12 11:21:41 -05:00
Peter Thorson 8ef8372af1 transport policy documentation 2013-08-12 11:16:59 -05:00
Peter Thorson 4a10d8ddfd iostream transport docs and code style 2013-08-12 11:16:45 -05:00
Peter Thorson f02c6f1c75 code style 2013-08-05 08:32:43 -05:00
Peter Thorson eb9ab6f70f add constexpr to static logging tests 2013-08-05 08:32:28 -05:00
Peter Thorson a2d92c9a21 style and documentation 2013-08-05 08:28:22 -05:00
Peter Thorson 6e23a6ec3c fix documentation bugs 2013-08-05 08:26:51 -05:00
Peter Thorson c30d000359 fix documentation typos, add client clarification 2013-07-31 22:42:55 -05:00
Peter Thorson ffe59ab078 documentation and code style 2013-07-30 22:13:56 -05:00
Peter Thorson e457467e9b Fix typo in .gitattributes, fixes #280 2013-07-27 11:29:34 -05:00
Peter Thorson 485304b438 Add missing locale include, fixes #281 2013-07-27 11:27:26 -05:00
Peter Thorson 3bab403c1b Refactor asio_transport and add full docs and exception free varient methods 2013-07-27 11:24:24 -05:00
Peter Thorson c017331959 remove trailing whitespace 2013-07-21 07:49:15 -05:00
Peter Thorson df828914c7 remove unneeded code and trailing whitespace 2013-07-21 07:38:27 -05:00
Peter Thorson 2c879ee797 Wrap ioservice run_one method. Fixes #278 2013-07-21 07:00:28 -05:00
Peter Thorson 241cf697f6 Suppress error when shutting down a closed connection 2013-07-17 07:28:26 -05:00
Peter Thorson c6f579a52a remove regex libs from CMAKE files 2013-07-17 07:26:53 -05:00
Peter Thorson 3f08de3d9d alpha3 release 2013-07-16 18:19:35 -05:00
Peter Thorson eb314e55de retry build 2013-07-15 11:08:05 -05:00
Peter Thorson ccbd93f725 add a debug mode switch 2013-07-15 10:41:32 -05:00
Peter Thorson be9a320fc1 Merge branch 'master' into permessage-deflate 2013-07-14 11:08:51 -05:00
Peter Thorson a9f3821d99 rename echo_client to testee client to better reflect its role 2013-07-14 11:02:59 -05:00
Peter Thorson 2964acd6d7 disable frame payload logging by default 2013-07-14 10:57:05 -05:00
Peter Thorson d564189d4c Merge pull request #274 from hobu/master
Implement conditional cmake configuration for echo_server_tls and add cmake config for print_server and telemetry_client
2013-07-14 08:56:17 -07:00
Peter Thorson ddca46f5d6 update changelog 2013-07-14 10:52:00 -05:00
Peter Thorson 7f062297de complete and clean up sha1 refactoring
move the remainder of documentation and licenses into sha1.hpp. Remove
unused files.
2013-07-14 10:49:40 -05:00
Peter Thorson 1c199aca6e minor refactoring of sha1 code
Update code style to better match project. Add more documentation. Add
some C++ specific features to improve compatibility and reduce warnings
with C++ applications. Add original project unit tests to WebSocket++
test suite.
2013-07-14 10:34:47 -05:00
Peter Thorson b8af39fd82 formatting 2013-07-13 13:29:10 -05:00
Peter Thorson c94621bd29 case insensitive header comparisons fixes #220 and #275 2013-07-13 13:28:56 -05:00
Peter Thorson 9a73b74a37 fix to ensure empty messages are handled correctly 2013-07-12 08:37:08 -05:00
Peter Thorson 48add58dc2 update compression tests 2013-07-12 08:35:49 -05:00
Peter Thorson e967ffc74d silence stratch server 2013-07-12 08:30:51 -05:00
Peter Thorson 475c478a2e protect against compress returning nothing 2013-07-12 08:29:34 -05:00
Howard Butler b83b054c7e add CMake config for print_server and telemetry_client 2013-07-11 10:54:43 -05:00
Peter Thorson b8d962950f impliment no_context_takeover options 2013-07-10 20:16:19 -05:00
Peter Thorson ba0094a0eb Merge branch 'master' into permessage-deflate
Conflicts:
	examples/scratch_client/SConscript
2013-07-10 19:10:03 -05:00
Howard Butler f6bcb86a6c Implement conditional cmake configuration for echo_server_tls 2013-07-10 16:09:38 -05:00
Peter Thorson 28ac69c800 temporary workaround for a g++ compile issue 2013-07-09 21:59:28 -05:00
Peter Thorson b866e4e0ca Refactors URI to be exception and regex free 2013-07-09 16:50:47 -05:00
Peter Thorson cdaf57cf7d update copyright date 2013-07-09 16:45:10 -05:00
Peter Thorson 2d49035a6d remove deprecated constants 2013-07-09 16:44:29 -05:00
Peter Thorson eb362007ab permessage_deflate tests 2013-07-09 07:14:14 -05:00
Peter Thorson 4d63c10be7 remove debug printing 2013-07-09 07:14:00 -05:00
Peter Thorson 686b835f3d update changelog 2013-07-08 19:02:14 -05:00
Peter Thorson 28f949d955 Merge branch 'master' into permessage-deflate 2013-07-08 18:12:21 -05:00
Peter Thorson 8f2c4264e1 Server header/User agent adjustments & tests
Updates behavior to drop the headers if user_agent is set to the empty
string and to allow overriding the Server header from the validate
function. Updates docs and adds a number of tests
2013-07-08 18:07:33 -05:00
Peter Thorson 11906dc2ce Adds is_server detection flag to deflate extension init 2013-07-08 16:15:45 -05:00
Peter Thorson c60e089553 add back to back message compression test 2013-07-08 16:10:03 -05:00
Peter Thorson b809bf3706 ensure that the masking key is initialized 2013-07-08 12:08:16 -05:00
Peter Thorson 6920b39aa2 fix unused variable 2013-07-08 12:00:29 -05:00
Peter Thorson f7376ccf46 fix missing return value 2013-07-08 12:00:21 -05:00
Peter Thorson 243cea16db update scratch examples 2013-07-08 11:58:43 -05:00
Peter Thorson 98a75b8cea fix order of masking key initialization and use 2013-07-08 11:52:51 -05:00
Peter Thorson 5323076007 update permessage_deflate tests 2013-07-08 11:43:15 -05:00
Peter Thorson d0d97b860b add permessage_deflate finalization code 2013-07-08 11:42:28 -05:00
Peter Thorson 25e8d522b2 refactor message finalization 2013-07-08 11:42:12 -05:00
Peter Thorson bd408944fd refactor message prep to determine payload size sooner 2013-07-08 11:38:42 -05:00
Peter Thorson 14aa71091f initialize deflate extension after it is negotiated 2013-07-08 11:37:29 -05:00
Peter Thorson 4607150f82 add error checking to decompress method 2013-07-08 11:36:52 -05:00
Peter Thorson 359f03fb1e Documentation 2013-07-08 11:36:00 -05:00
Peter Thorson 4a52e548fd compress outgoing messages by default if able 2013-07-08 11:35:43 -05:00
Peter Thorson 0501f77b57 Add additional development logging of incoming data 2013-07-08 11:35:29 -05:00
Peter Thorson 631261c365 correctly set avail_in for compression 2013-07-08 11:34:45 -05:00
Peter Thorson a90ccd83dd update error name to be more descriptive 2013-07-08 11:34:19 -05:00
Peter Thorson c103032e9c add init to extension interface 2013-07-08 11:34:07 -05:00
Peter Thorson 5c608910d5 fix interface mismatch 2013-07-05 11:44:20 -05:00
Peter Thorson 229698dbb0 add experimental connection get message buffer method 2013-07-05 11:41:47 -05:00
Peter Thorson c32bebba3e take over print server example for testing 2013-07-05 11:39:02 -05:00
Peter Thorson 6c6c6951e5 fix spelling error 2013-07-05 11:38:24 -05:00
Peter Thorson aeb0e8fa7d Merge branch 'master' into permessage-deflate 2013-07-03 06:32:22 -05:00
Peter Thorson 6bd1bfd4f2 add basic compression/decompression implimentation 2013-07-03 06:19:08 -05:00
Peter Thorson dbd0fc5372 remove debug printing 2013-07-03 06:16:42 -05:00
Peter Thorson 7454bf68f6 re-enable permessage_deflate test 2013-06-30 19:46:29 -05:00
Peter Thorson 5b7f4a8c14 remove unneeded methods 2013-06-30 19:39:03 -05:00
Peter Thorson 9dd53d2e28 code style 2013-06-30 19:38:50 -05:00
Peter Thorson 915f5c77a8 support c2s_max_window_size 2013-06-30 18:34:21 -05:00
Peter Thorson 36cae596db update documentation 2013-06-30 18:32:37 -05:00
Peter Thorson 407b931395 Add s2c_max_window_bits negotiation 2013-06-29 17:53:53 -05:00
Peter Thorson 25b530b8a8 fix bug that prevented multiple attributes from working 2013-06-27 19:49:13 -05:00
Peter Thorson 038a9aee58 setting and negotiation of c2s_no_context_takeover 2013-06-27 19:48:48 -05:00
Peter Thorson 9749c0a3d5 enable server initiated s2c_no_context_takeover 2013-06-27 19:02:28 -05:00
Peter Thorson c7b1ddd9fa permessage-deflate negotiation of s2c_no_context_takeover 2013-06-27 18:35:32 -05:00
Peter Thorson 7a0d9c0238 cleanup permessage deflate extension 2013-06-25 21:07:46 -05:00
Peter Thorson cb08f07cb0 add combination error code / string type 2013-06-25 20:59:29 -05:00
Peter Thorson 743cd7a713 HTTP cleanup and documentation 2013-06-25 20:57:30 -05:00
Peter Thorson 88fe1bfb1c Fix issue where pong timeout handler always fired 2013-06-24 14:59:19 -05:00
Peter Thorson 5fd65a934b fix typo 2013-06-24 13:35:25 -05:00
Peter Thorson bb1420fe06 endpoint code style 2013-06-24 13:33:06 -05:00
Peter Thorson 0264b63fc3 Add ping and pong endpoint wrapper methods 2013-06-24 13:32:56 -05:00
Peter Thorson 256f8325e8 spelling, documentation, and style 2013-06-23 21:06:33 -05:00
Peter Thorson ce410a9428 transport documentation and style 2013-06-23 19:41:48 -05:00
Peter Thorson 573dedcb9d transport code style 2013-06-23 16:26:37 -05:00
Peter Thorson 4f8b2bdc98 transport documentation & style 2013-06-23 16:18:03 -05:00
Peter Thorson 330d564ded Flags 64 bit literals in frame unit tests references #264 2013-06-22 20:10:49 -05:00
Peter Thorson 161a5b169a Merge pull request #262 from breyed/streamed-timestamp
Write timestamp directly to output stream
2013-06-22 17:59:03 -07:00
Peter Thorson 7d36965149 Add accessor for raw http requests references #266 2013-06-22 10:59:26 -05:00
Peter Thorson de5684aef3 add test fail handler 2013-06-22 10:50:28 -05:00
Peter Thorson fd93ad89cb update documentation and code style 2013-06-16 21:08:53 -05:00
Peter Thorson 6d620aa1e8 add documentation & update code style 2013-06-15 12:46:39 -05:00
Peter Thorson 816fe6410d update documentation & code style 2013-06-15 12:39:57 -05:00
Peter Thorson f3c65ab609 documentation 2013-06-15 12:34:11 -05:00
Peter Thorson c938d9fd15 use strict masking for incoming messages references #264 2013-06-14 21:55:14 -05:00
Peter Thorson 0b764bdc62 add byte_mask_circ 2013-06-14 21:49:24 -05:00
Peter Thorson 86e2f364de fix readme 2013-06-14 21:48:46 -05:00
Peter Thorson 54dd4c8084 look up version rather than hardcode 2013-06-14 21:48:29 -05:00
Peter Thorson cae30acf91 update byte mask to use separate input & output types references #264
In particular this allows const iterators to be use for the input types.
2013-06-12 20:52:48 -05:00
Peter Thorson 24c1804e40 update documentation 2013-06-12 19:23:05 -05:00
breyed 8c6a360600 Write timestamp directly to output stream
This uses put_time (if supported) to avoid having to first write the timestamp to a temporary buffer and then copy it to the stream.
2013-06-09 18:28:19 -05:00
Peter Thorson 5c35535ffd update changelog 2013-06-09 18:26:41 -05:00
Peter Thorson 3256c72d98 Merge pull request #261 from breyed/master
added guards to avoid macro definition when used with boost_config.hpp
2013-06-09 16:24:09 -07:00
breyed 07ab02407f added guards to avoid macro definition when used with boost_config.hpp 2013-06-09 18:03:49 -05:00
Peter Thorson edc0057a03 update unit test 2013-06-09 17:39:49 -05:00
Peter Thorson 9161119b4d bump version to alpha2 2013-06-09 17:24:24 -05:00
Peter Thorson 7db60e3429 fix poor server handling of double close frames fixes #259 2013-06-09 17:03:14 -05:00
Peter Thorson 3c0b8a81b0 Fix handling of spurious frames after close. Fixes #258 2013-06-09 16:41:04 -05:00
Peter Thorson b812fd001b Change default HTTP response error code to 426
Changes default HTTP response error code when no http_handler is
defined from 500/Internal Server Error to 426/Upgrade Required
2013-06-09 16:20:53 -05:00
Peter Thorson 3a43986d9e add documentation & normalize code style 2013-06-09 14:58:32 -05:00
Peter Thorson 64b1b52297 adds documentation on locations of version info 2013-06-09 11:07:19 -05:00
Peter Thorson dc048ed021 test use of doxygen todo command 2013-06-09 11:05:48 -05:00
Peter Thorson 60b167bcb7 updates changelog 2013-06-09 09:27:08 -05:00
Peter Thorson e680ca1ef4 add comment + TODO regarding VSPP warning 2013-06-09 09:25:30 -05:00
Peter Thorson 21d79e28c6 maybe fix markdown # escape? 2013-06-09 09:20:31 -05:00
Peter Thorson d25a254e81 remove logger dynamic allocation 2013-06-09 09:20:04 -05:00
Peter Thorson 3e144cfd75 Merge pull request #257 from zaphoyd/experimental
merge last bit of changes from experimental to master
2013-06-09 07:15:12 -07:00
Peter Thorson a5bb90807b Merge pull request #252 from breyed/visual-studio
Fixed Visual Studio 2012 warnings and formatting
2013-06-09 07:05:53 -07:00
Peter Thorson 096a7dbaa8 escape # in readme 2013-06-09 08:58:15 -05:00
Peter Thorson 577591aaa1 readme updates 2013-06-09 08:55:53 -05:00
Peter Thorson a401a4448d update version information to 0.3.0-alpha1 2013-06-09 08:46:54 -05:00
Peter Thorson ace76f54f9 update docs for 0.3.x in master branch fixes #197 2013-06-09 08:31:05 -05:00
Peter Thorson 1eaa1b790f update travis for 0.3.x in master 2013-06-09 08:30:03 -05:00
Peter Thorson c2a5f0bfa1 Merge pull request #255 from zaphoyd/0.3.x-cmake
merge final bits of 0.3.x-cmake into experimental
2013-06-09 06:13:59 -07:00
Peter Thorson b71b224860 Merge branch 'experimental' into 0.3.x-cmake 2013-06-09 08:13:02 -05:00
Peter Thorson be1d9fd64e Merge pull request #248 from resiprocate/0.3.x-cmake
Fix typo, add sip_client example (SIP over WebSockets)
2013-06-09 05:59:37 -07:00
Peter Thorson bcac77306f Merge pull request #254 from breyed/boost-config
Automatically configure platform via Boost.Config
2013-06-09 05:56:52 -07:00
Peter Thorson dd563c6647 corrects TCP close behavior references #227 fixes #25
Per RFC6455 clients prefer to wait for servers to initiate TCP close.
timers ensure that clients don't wait forever. Servers close TCP
immediately.
2013-06-09 07:36:55 -05:00
Peter Thorson 0ab1333a2f add transport integration helper handlers delay and close 2013-06-09 07:34:10 -05:00
Peter Thorson b9c66e9a7f transport integration test formatting cleanup 2013-06-09 07:33:48 -05:00
Peter Thorson 56e81cb6eb impliment close handshake timeouts references #226 2013-06-09 07:33:30 -05:00
Peter Thorson c228f70a9f complete handshake timeout references #226 2013-06-08 18:32:23 -05:00
Peter Thorson f35918ce6e split log_fail_result from log_close_result 2013-06-08 18:32:23 -05:00
Peter Thorson 33a0d89633 add transport integration dummy TCP client
client connects and never sends anything. the client ends on EOF
2013-06-08 18:32:23 -05:00
Peter Thorson bf582aa2c1 add unit test for server open handshake timeout 2013-06-08 18:32:23 -05:00
Peter Thorson 88c553f1fc silence unit tests 2013-06-08 18:32:23 -05:00
Peter Thorson 96270a9f3d add test for client opening handshake 2013-06-08 18:32:23 -05:00
Peter Thorson c6381a2311 start client handshake timer 2013-06-08 18:32:22 -05:00
Peter Thorson cff8604148 cancel handshake timers when handshake is complete 2013-06-08 18:32:22 -05:00
Peter Thorson dfcd8a2967 set detailed error code on terminate 2013-06-08 18:32:22 -05:00
Peter Thorson 593c26f087 fix devel debug comment 2013-06-08 18:32:22 -05:00
Peter Thorson 408639a0b5 whitespace 2013-06-08 18:32:22 -05:00
Peter Thorson b591e9fa7e add handshake timeout handlers 2013-06-08 18:32:22 -05:00
Peter Thorson f2486d4aef add handshake timer & associated handlers 2013-06-08 18:32:22 -05:00
Peter Thorson 1892e0f13b remove unused code 2013-06-08 18:32:22 -05:00
Peter Thorson 8ee6a4a64b set state to closing after we send our close frame 2013-06-08 18:32:22 -05:00
Peter Thorson c86601f123 add methods to retrieve WebSocket close codes & reasons 2013-06-08 18:32:22 -05:00
Peter Thorson 0f02119d48 adds new error codes for handshake timeouts 2013-06-08 18:32:22 -05:00
Peter Thorson 196523ba42 adds a machine readable internal error code
To be used for storing detailed error codes for why connections failed
or were closed
2013-06-08 18:32:22 -05:00
Peter Thorson 4a94a7c518 Merge pull request #253 from breyed/spelling
fixed spelling, including "experimental" in API
2013-06-08 09:19:41 -07:00
breyed e68d492ed2 Fixed Visual Studio 2012 warnings
Fixed daylight savings time formatting problem on Windows
2013-06-08 11:07:02 -05:00
breyed 808a8ce0a9 fixed spelling, including "experimental" in API 2013-06-08 11:03:11 -05:00
breyed cd8e1a25bb fixed comment at end of include guard 2013-06-08 10:34:09 -05:00
breyed 2352f09c68 Automatically configure platform via Boost.Config 2013-06-08 10:26:55 -05:00
Peter Thorson 55fa61feb1 Merge remote-tracking branch 'origin/0.3.x-cmake' into experimental 2013-06-08 09:29:53 -05:00
Peter Thorson 17083a4d4e Merge pull request #251 from jefferai/0.3.x-cmake
Add missing condition_variable include
2013-06-06 06:21:09 -07:00
Jeff Mitchell 2b6b4862ce Add missing condition_variable include 2013-06-05 14:12:13 -04:00
Daniel Pocock de4ad9e7f3 Add README for sip_client 2013-05-31 16:59:06 +02:00
Daniel Pocock 45e305b5c2 Fixes for sip_client new 0.3 API 2013-05-31 16:56:27 +02:00
Daniel Pocock 3dd3fd28d4 Correct the Via header for WS transport 2013-05-31 16:45:17 +02:00
Daniel Pocock 1dfa629ae4 Sending a SIP OPTIONS message 2013-05-31 15:45:34 +02:00
Daniel Pocock a549f2b99e Renaming contents of sip_client from echo_client 2013-05-31 14:47:41 +02:00
Daniel Pocock ca108ac693 Add examples/sip_client based on examples/echo_client 2013-05-31 14:45:54 +02:00
Daniel Pocock 7d513e1e11 Fix typo 2013-05-31 14:40:52 +02:00
Peter Thorson 2e2a8e4346 documentation and reorganization 2013-05-30 23:30:04 -05:00
Peter Thorson 808179551f remove dead code 2013-05-30 23:29:48 -05:00
Peter Thorson 38a565888f adds documentation 2013-05-30 18:05:34 -05:00
Peter Thorson dcb13d58be updates hybi00 to use new md5 header 2013-05-30 17:56:57 -05:00
Peter Thorson e8aa1e0e12 consolodates md5 code 2013-05-30 17:50:10 -05:00
Peter Thorson fcac7071eb adds documentation 2013-05-30 13:32:45 -05:00
Peter Thorson ea36bf1cf7 removes unused files 2013-05-30 13:32:33 -05:00
Peter Thorson 245978fd86 remove unneeded dependencies 2013-05-29 09:22:27 -05:00
Peter Thorson 6e0411020c fix broken package name 2013-05-29 09:17:17 -05:00
Peter Thorson ad2ff8ca0a fix travis script? 2013-05-29 09:15:37 -05:00
Peter Thorson 7e6d4212a5 only load boost libraries that we need to improve test times 2013-05-29 09:09:03 -05:00
Peter Thorson 7ca4f37c2c stop the server after the last connection ends and let the server thread clean up 2013-05-29 09:07:48 -05:00
Peter Thorson 370bd93182 remove exception suppression, test framework will catch these 2013-05-29 09:07:19 -05:00
Peter Thorson d9e3f626e2 use custom config so we can play with timer duration values 2013-05-29 09:06:46 -05:00
Peter Thorson b43717cd43 Merge branch 'experimental' of github.com:zaphoyd/websocketpp into experimental 2013-05-29 08:48:31 -05:00
Peter Thorson e4c4cf2018 updates readme and roadmap 2013-05-29 08:48:22 -05:00
Peter Thorson f0f346dabe experimental dual core travis build 2013-05-29 08:48:08 -05:00
Peter Thorson a29132e6f4 Merge pull request #245 from jefferai/0.3.x-cmake
Overload get_connection to allow passing in an already-constructed uri_p...
2013-05-28 10:39:59 -07:00
Jeff Mitchell 0a7aaa2632 Overload get_connection to allow passing in an already-constructed uri_ptr. This avoid the need for using the regex, which GCC does not implement yet. 2013-05-28 13:15:01 -04:00
Peter Thorson 10a8af1ac3 adds pong timer support and new full stack automated integration testing for it 2013-05-26 22:04:28 -05:00
Peter Thorson 5677b5f400 adds dummy timer support + tests to iostream transport 2013-05-26 20:02:08 -05:00
Peter Thorson f10e2d9b21 Merge pull request #240 from jefferai/0.3.x-cmake
Needs to be uppercase Version for case-sensitive systems
2013-05-26 12:36:27 -07:00
Peter Thorson ec8b73cad4 clarifies the purpose of utility client and removes contradictory comments references #242 2013-05-24 22:14:06 -07:00
Jeff Mitchell ca6aa12fbc Add websocketpp_found variable 2013-05-20 16:50:34 -04:00
Jeff Mitchell 2aea85a773 Needs to be uppercase Version for case-sensitive systems 2013-05-20 10:24:29 -04:00
Peter Thorson 2c09846722 Merge pull request #239 from zaphoyd/experimental
updates cmake branch with latest changes
2013-05-18 05:05:00 -07:00
Peter Thorson 8f8bbb99e9 adds more unit tests for http requests 2013-05-18 06:56:49 -05:00
Peter Thorson d7e5235036 extract URI for HTTP connections also 2013-05-18 06:54:56 -05:00
Peter Thorson dd534ace64 switches processor to use new free get_uri function 2013-05-18 06:54:32 -05:00
Peter Thorson 065dd26779 adds free processor extract uri from request utility method 2013-05-18 06:53:46 -05:00
Peter Thorson 8c6b049e99 adds better support for custom URI schemes 2013-05-18 06:53:17 -05:00
Peter Thorson f988315ea8 updates broadcast_server to use common/thread rather than hardcoding boost thread 2013-05-16 10:31:02 -05:00
Peter Thorson 4474868372 adds unique_lock and condition_variable to common thread tools 2013-05-16 10:30:38 -05:00
Peter Thorson 5c4719080c Merge pull request #236 from jefferai/0.3.x-cmake
CMake fixes/enhancements
2013-05-15 06:40:02 -07:00
Jeff Mitchell 980fa8db67 Create -config and -configversion files so find_package in other
CMake-using applications works to include websocketpp. Also, a lot of
cleanup.
2013-05-15 08:23:37 -04:00
Peter Thorson f3faf404dd merge from experimental 2013-05-14 15:22:22 -05:00
Peter Thorson a2a02ba063 adds a debug log statement 2013-05-14 15:14:57 -05:00
Peter Thorson 3c015ca356 Merge pull request #232 from jefferai/0.3.x-cmake
Actually recursively install header files.
2013-05-13 07:06:33 -07:00
Peter Thorson 19edfe3c60 adds tests for TLS timers 2013-05-13 09:05:31 -05:00
Peter Thorson a8f649892f renames mock logger to stub logger 2013-05-13 09:03:12 -05:00
Peter Thorson 27d5ec3394 adds Doxygen file 2013-05-13 07:53:41 -05:00
Peter Thorson d8310780ac adds documentation 2013-05-13 07:50:43 -05:00
Peter Thorson a77d92e99a switches the order of error and access log paramters to be consistent with the rest of the library 2013-05-13 07:50:29 -05:00
Jeff Mitchell e88b30e94d Don't use Doxygen in the standard cmake build dir 2013-05-12 10:26:31 -04:00
Jeff Mitchell c6f3ce4d39 Actually recursively install header files. 2013-05-11 18:51:44 -04:00
Peter Thorson 4a4c763d18 Merge pull request #231 from zaphoyd/experimental
bring cmake branch in line with experimental
2013-05-11 13:57:46 -07:00
Peter Thorson ae207afb10 Merge pull request #230 from jefferai/0.3.x-cmake
Add basic Doxyfile
2013-05-11 13:51:06 -07:00
Peter Thorson 0d7677b1b1 use travis for all 0.3.x branches 2013-05-11 15:50:47 -05:00
Peter Thorson c3d484f1ea preliminary work on unit tests for timers 2013-05-11 15:49:48 -05:00
Peter Thorson 0a4995bce5 adds missing include files 2013-05-11 15:48:32 -05:00
Peter Thorson 8f7843094d edits for consistency 2013-05-11 15:48:21 -05:00
Peter Thorson 738822813f Adds an empty mock logger 2013-05-11 15:47:56 -05:00
Jeff Mitchell c3fb69833c Add basic Doxyfile 2013-05-11 16:09:23 -04:00
Peter Thorson 5bd0332d19 return error code by value rather than reference 2013-05-11 09:43:09 -05:00
Peter Thorson cb5955ccc5 defines timers before using them 2013-05-11 09:40:19 -05:00
Peter Thorson 2f050cf412 updates socket policy error handling 2013-05-11 09:36:42 -05:00
Peter Thorson 67edd83a7c adds post_init (tls) and shutdown timers references #226 2013-05-11 07:11:00 -05:00
Peter Thorson c8f603ed1c simplify tls async shutdown 2013-05-11 07:09:59 -05:00
Peter Thorson d37dd26f43 rename config constants for consistency 2013-05-11 07:09:42 -05:00
Peter Thorson 3ac8a99cec fixes some typos 2013-05-10 17:18:33 -05:00
Peter Thorson 58fd1b80c2 refactors dns resolve timer to be more robust and adds connect timer 2013-05-10 17:17:13 -05:00
Peter Thorson 43ba642b53 removes timeouts from socket policy (moving them a level up) 2013-05-10 17:13:46 -05:00
Peter Thorson 4e06c837ff adds post/pre init and connect timeout values to default configs 2013-05-10 17:07:52 -05:00
Peter Thorson b23c7fd93a define NOMINMAX to fix VCPP warnings references #203
reported by KHeresy
2013-05-10 16:08:46 -05:00
Peter Thorson 8966c88d2f add platform specific preprocessor settings section 2013-05-10 16:04:43 -05:00
Peter Thorson e2462ec30b use endpoint set_timer rather than connection 2013-05-10 16:02:33 -05:00
Peter Thorson 4adfc452d0 adds more robust proxy timeout behavior 2013-05-10 08:43:37 -05:00
Peter Thorson 80990aaec9 adds travis build status to readme 2013-05-10 07:08:59 -05:00
Peter Thorson 34327a69c6 disable travis ci clang build on ubuntu until scons can be fixed 2013-05-09 20:03:25 -05:00
Peter Thorson 92ff87c144 install boost libraries, not just headers 2013-05-09 19:55:39 -05:00
Peter Thorson 0ec7c187b8 libs not plural 2013-05-09 19:49:51 -05:00
Peter Thorson 6780d15bee invalid yml! 2013-05-09 19:47:15 -05:00
Peter Thorson e4467487e0 travis ci update 2013-05-09 19:46:06 -05:00
Peter Thorson 257149e9db experimental travis-ci support references #171 2013-05-09 19:43:35 -05:00
Peter Thorson d83c2913b2 add user manual to readme 2013-05-09 19:43:35 -05:00
Peter Thorson 16999a14c7 fixes some silly mistakes references #229 2013-05-09 16:35:39 -05:00
Peter Thorson 4d0a1c98a9 optimization level 2/3 fails to pass unit tests. need to investigate 2013-05-09 16:34:47 -05:00
Peter Thorson 49a866dc8e test line breaks 2013-05-09 07:18:30 -05:00
Peter Thorson 837b9f82ae update readme 2013-05-09 07:16:15 -05:00
Peter Thorson e9553268fd update email 2013-05-09 07:14:02 -05:00
Peter Thorson 11a4fc4132 fix spacing 2013-05-09 07:13:23 -05:00
Peter Thorson 80ea946938 fix italic formatting 2013-05-09 07:12:45 -05:00
Peter Thorson 273c8e82b0 updates non-code supporting documentation 2013-05-09 07:11:59 -05:00
Peter Thorson 98c8c2ae5c Merge pull request #228 from zaphoyd/experimental
Merge experimental into 0.3.x-cmake
2013-05-09 04:35:11 -07:00
Peter Thorson 7a0a987f57 Merge pull request #225 from jefferai/0.3.x-cmake
More CMake updates
2013-05-09 04:32:59 -07:00
Peter Thorson d85ea32851 adds timer support to asio endpoints, impliments dns resolve timer references #226 2013-05-08 08:52:52 -05:00
Peter Thorson b408ab876e adds method to set proxy timeout duration at runtime 2013-05-07 20:45:28 -05:00
Peter Thorson 747bc55bcf adds documentation and error handling to proxy methods 2013-05-07 20:45:04 -05:00
Peter Thorson fd46083c4a updates frame unit tests to use more specific checks 2013-05-07 20:34:17 -05:00
Peter Thorson 5d0d1379b6 adds timer support for asio transport and adds proxy connect timeout references #226 2013-05-07 17:49:02 -05:00
Peter Thorson 175cab8d22 updates configs to add default timer wait times references #226 2013-05-07 17:46:41 -05:00
Peter Thorson bda4cf3a46 updates derived configs to also derive transport_config from base 2013-05-07 17:46:17 -05:00
Peter Thorson 96158ee8b5 print get connection errors 2013-05-07 13:07:36 -05:00
Peter Thorson 215c9bcdab adds better debugging options for the scons build system 2013-05-07 13:07:35 -05:00
Jeff Mitchell 92651f1f14 Affect the install location for headers only; honor the normal/given install prefix otherwise. 2013-05-07 12:47:33 -04:00
Jeff Mitchell 693fa27fed Make finding boost conditional upon examples being built; remove building when possible by only using header versions of files 2013-05-07 12:38:41 -04:00
Peter Thorson 8e40c53f97 adds new async terminate interface which significantly improves error handling 2013-05-07 09:38:26 -05:00
Peter Thorson 6bd62edb43 removes unused code & updates naming conventions 2013-05-07 09:37:37 -05:00
Peter Thorson 75af01cda4 updates asio transport base unit tests for new interface 2013-05-07 09:35:48 -05:00
Peter Thorson 42ca501f76 adds async_shutdown interface to transport connections 2013-05-07 09:35:13 -05:00
Peter Thorson 7d8f1ea163 revert ignore of TLS short read references #224 2013-05-07 07:02:17 -05:00
Peter Thorson b0cf22c66b Merge pull request #222 from jefferai/0.3.x-cmake
Fix a number of CMake-related issues
2013-05-06 12:09:56 -07:00
Jeff Mitchell 0aba4f3695 Fix a number of CMake problems: clang detection, shared library support, etc. 2013-05-06 13:12:02 -04:00
Jeff Mitchell 5c9de71415 Merge remote-tracking branch 'upstream/experimental' into 0.3.x-cmake 2013-05-06 13:09:40 -04:00
Peter Thorson 4807d54155 corrects visual studio 2008 temporary overflow debug warning references #221 2013-05-06 08:23:40 -05:00
Peter Thorson 3304647c3f removes stray space from proxy auth header references #132 2013-05-06 08:22:03 -05:00
Peter Thorson b2fbb7b8ba registers missing handlers 2013-05-05 19:09:03 -05:00
Peter Thorson f6f4befe46 adds new tls_short_read transport error 2013-05-05 19:06:55 -05:00
Peter Thorson dc7872d647 test ignoring TLS short reads 2013-05-05 18:57:17 -05:00
Peter Thorson 844334efbb fixes perftest constructor call 2013-05-05 18:47:30 -05:00
Peter Thorson 2dcc87a7d3 fixes incorrect duration type 2013-05-05 18:46:30 -05:00
Peter Thorson 0ff8bbfbb7 adds proper close status 2013-05-05 18:43:33 -05:00
Peter Thorson 971482e0b8 typos 2013-05-05 18:42:00 -05:00
Peter Thorson b4edb1be06 some stuff for performance testing 2013-05-05 18:38:10 -05:00
Peter Thorson 3da5bb6b2c don't block on SSL shutdown 2013-05-05 18:09:16 -05:00
Peter Thorson b1f9e9b069 send absolute authority to proxy init 2013-05-05 17:28:25 -05:00
Peter Thorson 3fcc3b6b75 adds the ability to get the absolute authority of a uri 2013-05-05 17:28:03 -05:00
Peter Thorson 03e6f6dd11 ugh tabs 2013-05-05 17:16:13 -05:00
Peter Thorson b29a2f3456 removes old code 2013-05-05 17:12:13 -05:00
Peter Thorson adb0eedc24 splits transport init into pre-and post proxy steps 2013-05-05 16:14:38 -05:00
Peter Thorson cb40f81978 adjusts how remote endpoint logging is printed 2013-05-05 15:15:53 -05:00
Peter Thorson 24f6943336 fixes more typos 2013-05-05 15:13:45 -05:00
Peter Thorson ced601f8d7 fixes some typos 2013-05-05 15:12:34 -05:00
Peter Thorson c1e0545d58 adds debug logging for the connect and dns resolve seps 2013-05-05 12:18:23 -05:00
Peter Thorson d908c1afd2 update copyright dates and fix whitespace that doesn't match projec style 2013-05-05 11:23:31 -05:00
Peter Thorson 3c9f3206c5 tls support for utility client 2013-05-04 14:25:21 -05:00
Peter Thorson 2fa6e6f4d4 security policy socket_init handler now uses tls socket stream type rather than raw socket 2013-05-04 14:25:11 -05:00
Peter Thorson 8dad7aba45 propogate handle setting through to the security policy 2013-05-04 14:24:24 -05:00
Peter Thorson c559e0a623 connection initialization errors are properly logged and propogated 2013-05-04 11:52:52 -05:00
Peter Thorson 6561a9be20 adds security policy interface documentation 2013-05-04 11:52:13 -05:00
Peter Thorson 54fdf1af72 adds transport policy interface documentation 2013-05-04 11:51:55 -05:00
Peter Thorson 5440ecfcb7 adjusts variable names to match coding style 2013-05-04 11:50:52 -05:00
Peter Thorson d44131397e Merge pull request #219 from jonnenauha/cmake_prebuild_system
Cmake prebuild system against 0.3.x-cmake
2013-05-03 19:06:53 -07:00
unknown 1e6c1f9807 Merge remote-tracking branch 'upstream/0.3.x-cmake' into cmake_prebuild_system
Conflicts:
	websocketpp/endpoint.hpp
2013-05-04 02:07:17 +03:00
Peter Thorson b6a741ed23 fixes utility client tls settings 2013-05-03 17:12:51 -05:00
Peter Thorson 8906f19caa fixes asio tls client config name 2013-05-03 17:12:43 -05:00
Peter Thorson 28eecb80e0 adds utility client example 2013-05-03 17:08:05 -05:00
Peter Thorson 64f7e24b4d read proxy info from the right socket 2013-05-03 14:32:35 -05:00
Peter Thorson 380116b3df un-breaks VCPP and doesn't seem to affect anything else 2013-05-03 11:20:42 -05:00
Jonne Nauha db0a2eb7f5 Fix stdint.hpp for <=VC9. 2013-05-03 11:20:08 -05:00
Peter Thorson cde8a9e204 wites proxy connect to next layer 2013-05-03 08:41:50 -05:00
Peter Thorson 84283db1e5 adds wrapper for getting the next layer of the socket stack to tls and basic templates 2013-05-03 08:41:38 -05:00
Peter Thorson 14e80a4ff1 detab 2013-05-03 08:33:43 -05:00
Peter Thorson 0cba06bd67 fixes error namespacing 2013-05-03 08:33:12 -05:00
Peter Thorson 05fb9aadb1 detab 2013-05-03 08:32:59 -05:00
Peter Thorson 87da82698f re-orders methods properly 2013-05-03 08:32:52 -05:00
Peter Thorson 2cebf3a30b adds proxy basic auth support references #132 2013-05-03 08:00:41 -05:00
Peter Thorson 8f35121445 write proxy connect to the raw socket references #132 2013-05-03 07:59:47 -05:00
Peter Thorson 1e2762e648 adds error handling to proxy initiation 2013-05-03 07:57:08 -05:00
Peter Thorson d9d3804e5f adds convenience method to base64 encode strings 2013-05-03 07:56:09 -05:00
Peter Thorson 5be8ecca87 impliments hybi00 close frames references #195 2013-05-02 19:28:29 -05:00
Peter Thorson b06ba38fce removes debug printing 2013-05-02 19:26:13 -05:00
Peter Thorson 24774fc124 adds a bunch of explicit casts where signedness or truncation occurs references #218 2013-05-01 08:24:02 -05:00
Peter Thorson 0905b7d4e9 switches static to reinterpret_cast references #218 2013-05-01 07:00:37 -05:00
Peter Thorson 754651c9eb readme status update 2013-05-01 06:42:05 -05:00
Peter Thorson 04bbb4aa43 cleans up acceptor on destruction of endpoint transport component references #217 2013-05-01 06:23:11 -05:00
Peter Thorson b0b7f5e586 explicitly casts assignments with differing signedness references #218 2013-05-01 06:18:21 -05:00
Peter Thorson 371aa07180 fixes SConscript name comment 2013-05-01 06:10:16 -05:00
Peter Thorson c13ec1beb7 adds set(none) as alias for clear all references #207 2013-04-30 17:53:07 -05:00
Peter Thorson 00c29e42ac disable circshift test for a bit 2013-04-30 17:43:48 -05:00
Peter Thorson 40c10ff6e7 potential endianness fix 2013-04-30 17:42:36 -05:00
Peter Thorson df8d7f3f0d unit test fix 2013-04-30 17:21:16 -05:00
Peter Thorson f110b0bc65 potential solution for PPC masking bug 2013-04-30 17:14:34 -05:00
Peter Thorson 568743e587 fixes bug in unit test 2013-04-30 17:14:22 -05:00
Peter Thorson 54a9ed6e24 Fixes isystem flag 2013-04-30 17:14:11 -05:00
Peter Thorson 5ee8000b12 updates readme progress report 2013-04-29 16:58:53 -05:00
Peter Thorson be07587659 removes expensive development logging from non-debug builds 2013-04-29 13:06:17 -05:00
Peter Thorson 865da6dba2 allow end user dynamic tests 2013-04-29 13:03:25 -05:00
Peter Thorson 4b99ad7ed4 Merge pull request #216 from oberstet/experimental
add testee server
2013-04-28 11:11:12 -07:00
Tobias Oberstein d4f2b6083d logging: total silence 2013-04-28 20:06:28 +02:00
Tobias Oberstein eeb6d778ff add testee server 2013-04-28 19:54:25 +02:00
Peter Thorson 2c3892bb56 Merge pull request #215 from oberstet/experimental
some Windows build fixes
2013-04-28 08:15:32 -07:00
Tobias Oberstein 53a7a67d80 some Windows build fixes 2013-04-28 17:09:09 +02:00
Peter Thorson a500ec144f allow proxies to work with secure websockets 2013-04-27 22:15:21 -05:00
Peter Thorson 5d71935441 completes basic client proxy support references #132 2013-04-27 13:58:33 -05:00
Peter Thorson 2a71b89bbc better debug messages 2013-04-27 13:57:44 -05:00
Peter Thorson ea7ac38ed7 bugfixes and tests for new http istream consume 2013-04-27 13:55:25 -05:00
Peter Thorson aaaa2b4a65 updates uri unit tests to allow http schemes 2013-04-27 13:54:57 -05:00
Peter Thorson bb702c6589 update URI to be able to store and manipulate HTTP URIs 2013-04-27 13:15:41 -05:00
Peter Thorson de1ceff418 initial work on client proxy support references #132 2013-04-26 08:56:18 -05:00
Peter Thorson ca8716ae53 remove unused code 2013-04-26 08:55:56 -05:00
Peter Thorson 64eb09db06 initial work on istream input for http parsers 2013-04-26 08:55:36 -05:00
Peter Thorson 1bbb0cba7f readme update 2013-04-26 08:55:04 -05:00
Peter Thorson 1f194ea327 hybi00 unit test bugfix 2013-04-26 08:54:58 -05:00
Peter Thorson e6c0a7b506 refactor configs to remove duplicate code and add http processor types to transport config 2013-04-26 08:54:40 -05:00
Peter Thorson f46b305df8 fixes typo, references #213 2013-04-26 06:15:42 -05:00
Peter Thorson fe28f29ab4 updates readme 2013-04-25 19:48:47 -05:00
Peter Thorson d9d6338cc2 adds some additional debugging output 2013-04-25 18:55:21 -05:00
Peter Thorson 5e50387596 adjusts some hybi00 handshake settings 2013-04-25 18:54:48 -05:00
Peter Thorson b4c2bfd13a adds hybi00 frame read code + tests 2013-04-25 08:52:21 -05:00
Peter Thorson 66a3db1740 note that hybi13 processor needs incoming message buffer validation 2013-04-25 08:51:57 -05:00
Peter Thorson 34a9d47b9c adds error type for no incoming message buffers 2013-04-25 08:51:25 -05:00
Peter Thorson d4be2a9b4d more frame writing unit tests 2013-04-25 06:36:09 -05:00
Peter Thorson 6095b90cc1 adds hybi00 support for writing messages 2013-04-25 06:27:36 -05:00
Peter Thorson 285069b178 final cleanup 2013-04-24 07:47:58 -05:00
Peter Thorson 6359f3bb0a clean up 2013-04-24 07:25:42 -05:00
Peter Thorson 94919f125c character by character experiment 2013-04-24 07:21:58 -05:00
Peter Thorson e304deacad typo 2013-04-24 07:03:36 -05:00
Peter Thorson 0bc908674a flush logger output 2013-04-24 07:02:39 -05:00
Peter Thorson d1e05df4fa some logging 2013-04-24 07:00:39 -05:00
Peter Thorson 1081fcb6ef tests with iostream_server 2013-04-24 06:56:59 -05:00
Peter Thorson 948d9a487f fixes missing return value 2013-04-23 21:15:17 -05:00
Peter Thorson d40321333a additional documentation and cleanup 2013-04-23 13:37:51 -05:00
Peter Thorson 04244da3f9 small logic cleanup 2013-04-23 13:28:54 -05:00
Peter Thorson fbdc122774 adds an fail handler to telemetry client 2013-04-23 13:23:53 -05:00
Peter Thorson 04f4aab1a9 default connection close status is the abnormal close rather than 0 2013-04-23 13:23:15 -05:00
Peter Thorson 5c9be64230 pass through endpoint errors are now filed under info rather than devel 2013-04-23 13:23:02 -05:00
Peter Thorson 648c387048 adds some explanatory comments 2013-04-23 12:41:35 -05:00
Peter Thorson 72b3def6d6 tabs to spaces 2013-04-23 12:35:05 -05:00
Peter Thorson f51960e8ff adds telemetry client example 2013-04-23 12:33:25 -05:00
Peter Thorson c68e2207c2 adds print server example 2013-04-23 12:33:18 -05:00
Peter Thorson b9ec2d5ae9 removes raw debugging output 2013-04-23 12:33:05 -05:00
Peter Thorson c2fe98c9a4 cleans up session::state values 2013-04-23 12:32:45 -05:00
Peter Thorson a10a5a7bcd adds lib::thread 2013-04-23 12:32:13 -05:00
Peter Thorson 5f87341e9e adds file based logging to iostream server 2013-04-23 10:03:56 -05:00
Peter Thorson 6fe8d8a4f9 ignore log files 2013-04-23 10:03:31 -05:00
Peter Thorson 1421403603 adds ability to set arbitrary stream for logging 2013-04-23 10:03:24 -05:00
Peter Thorson 30d3c8a895 removes cout statement 2013-04-23 10:03:04 -05:00
Peter Thorson 07a4394ba6 new iostream example 2013-04-23 09:26:57 -05:00
Peter Thorson e7483e82ac adds manual input options for iostream transport 2013-04-23 09:26:50 -05:00
Peter Thorson cd8b467225 expected EOF after clean close no longer triggers fatal error references #209 2013-04-20 09:30:02 -05:00
Peter Thorson d987f7b0d5 user agent strings in connect logging are now properly quoted 2013-04-20 08:56:45 -05:00
Peter Thorson 91250fcd54 adds a string_replace_all utility function 2013-04-20 08:56:19 -05:00
Peter Thorson 466c9bd626 removes redundant code from echo_server 2013-04-20 08:34:58 -05:00
Peter Thorson 72b5fada72 adds close result logging 2013-04-20 08:34:28 -05:00
Peter Thorson ea3426868c adds asio transport eof error detection 2013-04-20 08:33:53 -05:00
Peter Thorson f877098f7c fixes debug config 2013-04-20 08:33:27 -05:00
Peter Thorson 4c1abab02b removes unneeded dependencies and makes base64 validation more strict references #209 2013-04-20 07:44:06 -05:00
Peter Thorson 98171d525e adds C++ namespaces to <cstring> methods references #209 2013-04-20 07:30:52 -05:00
Peter Thorson 4ada7f9b0b updates asio transport endpoint with a few more io_service convenience pass through methods references #211 2013-04-20 07:25:34 -05:00
Peter Thorson 4bc4518df0 Fixes send buffer going out of scope, references #209 2013-04-16 11:26:13 -05:00
Peter Thorson 16f28ea671 adds debug/devel configs 2013-04-12 08:13:28 -05:00
Peter Thorson 894124c042 improves error reporting and adds remote endpoint address to connection open logging 2013-04-12 08:13:18 -05:00
Peter Thorson b12bff7d5d impliments get_remote_endpoint for asio transport 2013-04-12 08:12:45 -05:00
Peter Thorson b38e41e459 some test work on removing uri regex dependency 2013-04-12 08:12:21 -05:00
Peter Thorson 6a37bf3a43 update copyright date 2013-04-12 08:11:48 -05:00
Peter Thorson 5e595d7fe6 adds error logging config settings to clients 2013-04-12 08:11:36 -05:00
Peter Thorson c8fada14f7 adds configurable static logging channels 2013-04-08 09:44:32 -05:00
Peter Thorson 1e97e3dcf5 adds connection client methods for adding subprotocols to the handshake request 2013-04-07 12:18:03 -05:00
Peter Thorson a9b30b6b07 updates processors to support writing handshake requests with subprotocols 2013-04-07 12:17:10 -05:00
Peter Thorson bfbb4a94db adds an example to demonstrate subprotocol negotiation 2013-04-06 15:30:58 -05:00
Peter Thorson 51caf0517e adds support for retrieving headers from the request and response objects 2013-04-06 15:30:35 -05:00
Peter Thorson d47327d2a6 updates readme progress list 2013-04-06 12:12:35 -05:00
Peter Thorson 0c9c121160 moves subprotocol extraction into the processor 2013-04-06 12:10:39 -05:00
Peter Thorson ddd1a95460 refactors hybi00 unit tests to remove duplicate code and use more specific BOOST checks 2013-04-06 12:10:16 -05:00
Peter Thorson 17fcb3f8be adds subprotocol selection to connection 2013-04-06 11:09:41 -05:00
Peter Thorson 8f812aafd5 adds subprotocol processing to handshake processors 2013-04-06 11:09:11 -05:00
Peter Thorson 6d1b956aff adds preliminary server side subprotocol negotiation 2013-04-05 21:10:19 -05:00
Peter Thorson 10db03d710 more work on subprotocol tests 2013-04-05 09:30:15 -05:00
Peter Thorson 9f0649cb91 adds integration tests for the server role 2013-04-05 08:29:17 -05:00
Peter Thorson 8c7c31362d Adds storage and getter for negotiated subprotocol 2013-04-05 08:28:54 -05:00
Peter Thorson 1f450fd034 refactors connection testing to extract more common functionality 2013-04-05 08:28:13 -05:00
Peter Thorson 9ebd169675 fixes a crash when strftime overflowed buffer #205 2013-04-05 07:29:20 -05:00
Peter Thorson c937f71b49 changes extension permessage-compress to permessage-deflate per latest draft spec 2013-04-04 08:18:39 -05:00
Peter Thorson dff7a57e3d updates HTTP parser to use an ordered list of parameters rather than unordered
order matters as far as websocket extension negotation goes
2013-04-04 08:18:05 -05:00
Jonne Nauha df4d7167fd CMake continued: Try to detect g++, clang, windows and osx and setup appropriate defines and build flags. Improve so that each setup can define platform, boost and ssl libs. I tried to copy everything that I could from the scons scripts, probably some of this can be removed (might be automated from cmake already), left todo:s for that. Added building simple examples, more to follow. NOTE: This has only been tested on windows. 2013-04-03 01:56:10 +03:00
Jonne Nauha 75b2497f2b Fix intrusive_ptr template init on windows. The second template argument should probably be removed if its not neccesary for other platforms. I did not find boost documentation for what the second argument actually does, but in the meanwhile ifdeffed so that builds on windows (yes its ugly). Fixes #198 (with a semi hack). 2013-04-03 01:52:22 +03:00
Jonne Nauha 834e3e4fae Fix stdint.hpp for <=VC9. 2013-04-03 01:48:35 +03:00
Jonne Nauha e039a57ee0 CMake prebuild system: Initial commit that has most of the basics down. Only tested on windows atm. TODO: Properly support examples, tests and cpp11 defines to build websocketpp in different setups. 2013-04-01 17:48:47 +03:00
Peter Thorson 73e877f1b8 removes unused headers to avoid confusion references #202 2013-04-01 08:43:43 -05:00
Peter Thorson 7739d4fe72 updates readme 2013-03-31 21:43:22 -05:00
Peter Thorson a8e3ae47dd more readme updates 2013-03-31 21:35:11 -05:00
Peter Thorson dcdeb96c62 readme updates 2013-03-31 21:21:39 -05:00
Peter Thorson f38acd5784 impliments the autobahn echo client spec to allow autobahn test suite to test the client 2013-03-31 21:20:14 -05:00
Peter Thorson 800028d1a9 Changes HTTP response parser behavior to only read response bodies when a content length header is present 2013-03-31 21:16:33 -05:00
Peter Thorson 8587647657 Adds echo_client example 2013-03-31 15:12:57 -05:00
Peter Thorson babe00bc60 adds default client configs 2013-03-31 15:12:09 -05:00
Peter Thorson 35dbc8c8aa adds asio async connect and resolve functionality 2013-03-31 15:11:58 -05:00
Peter Thorson 7a1e9a2f59 fixes connection client bug where it would wait for the HTTP body to be read when there wasn't one 2013-03-31 15:11:39 -05:00
Peter Thorson e7e0c05e9a async_connect requires uri as a parameter now 2013-03-31 15:11:05 -05:00
Peter Thorson 4d78ba6daf fixes typo 2013-03-31 15:10:09 -05:00
Peter Thorson 859689bdf7 removes extraneous debug code 2013-03-31 15:09:59 -05:00
Peter Thorson 439efa0895 adds getter for connection uri part 2 2013-03-31 15:09:42 -05:00
Peter Thorson 2d35726edb adds getter for connection URI 2013-03-31 15:09:17 -05:00
Peter Thorson 7efcf1b047 processors now generate correct random masking keys 2013-03-31 15:08:43 -05:00
Peter Thorson 8a083528a2 finishes client handshake processing 2013-03-31 12:38:47 -05:00
Peter Thorson 13ec782a4f lots of tests 2013-03-31 12:37:59 -05:00
Peter Thorson aec59a1eb9 adds client handshake request generation and server response validation 2013-03-31 12:37:43 -05:00
Peter Thorson 6659846b2e extracts a method for processing handshake keys 2013-03-31 12:37:20 -05:00
Peter Thorson 45198eb4c6 major overhaul to processor unit tests to reduce duplicated code 2013-03-31 10:49:31 -05:00
Peter Thorson c5842802e2 turns on error reporting by default 2013-03-31 09:24:53 -05:00
Peter Thorson f423d051ee adds a new processor error code 2013-03-31 09:24:31 -05:00
Peter Thorson 1475e30930 updates http constants to match the code style of the rest of the library 2013-03-31 09:24:15 -05:00
Peter Thorson 46fb7e6645 adds more logic for reading client handshake responses 2013-03-30 22:41:57 -05:00
Peter Thorson ddddef5444 updates to unit tests to support new connection and processor api that includes RNG 2013-03-30 20:12:37 -05:00
Peter Thorson 67c740e264 adds HTTP request sending to connections 2013-03-30 19:55:40 -05:00
Peter Thorson cb6c396a6b adds handshake request processing to hybi13 and 00 processors 2013-03-30 19:55:04 -05:00
Peter Thorson f494c72006 adds RNG support for endpoints, connections, and processors 2013-03-30 19:54:26 -05:00
Peter Thorson 39c278a871 Adds the ability to detect and use constexpr to the C++11 common header 2013-03-30 17:49:56 -05:00
Peter Thorson b5b2fb9e0a adds default client version to core config 2013-03-30 17:49:35 -05:00
Peter Thorson 837d9eef9f Fixes a member variable that was not initialized before use 2013-03-30 17:48:35 -05:00
Peter Thorson 26d601e7c4 impliments async connect for iostream transport 2013-03-30 07:57:10 -05:00
Peter Thorson 3eef03d31e disables termination of connections that return bad handles 2013-03-30 07:56:50 -05:00
Peter Thorson 924bb1a050 adds client endpoint connection methods 2013-03-30 07:55:05 -05:00
Peter Thorson f2d939ab37 moves transport endpoing base types into the right file 2013-03-30 07:54:36 -05:00
Peter Thorson 8ced80b2ed adds method to retrieve connection handle from iostream connections 2013-03-30 07:53:45 -05:00
Peter Thorson 1ddd43ccb0 client get_connection now sets URI 2013-03-30 07:05:31 -05:00
Peter Thorson 7afcd866a0 adds the ability to set a connection URI outside of the server handshake 2013-03-30 07:05:08 -05:00
Peter Thorson afd5646ca5 adds more client functionality and associated tests 2013-03-28 22:58:54 -05:00
Peter Thorson 0b0106a97f adds is_secure method to transport endpoint 2013-03-28 22:58:39 -05:00
Peter Thorson 4f00240a3b adds preliminary foundations for client support 2013-03-28 22:43:55 -05:00
Peter Thorson e2489001cf adds connection dependencies 2013-03-28 22:43:23 -05:00
Peter Thorson 842c5749fc adds more error codes 2013-03-28 22:43:07 -05:00
Peter Thorson ef857ea831 splits basic logger from log constants 2013-03-28 22:42:51 -05:00
Peter Thorson e54c890b4b adds role unit test modules 2013-03-28 22:41:51 -05:00
Peter Thorson dfd61f8504 updates copyright dates 2013-03-28 22:41:23 -05:00
Peter Thorson 91c1e59ec4 fixes a legacy/hybi00 handshake processing bug on 32 bit x86 2013-03-28 08:23:59 -05:00
Peter Thorson ff04d307e5 Updates readme 2013-03-19 11:29:41 -05:00
Peter Thorson 45092c9633 adds get_io_service to asio transport 2013-03-17 22:57:27 -05:00
Peter Thorson ceea7f7be9 adds additional C++11 library blacklist defines 2013-03-17 22:10:08 -05:00
Peter Thorson 59d7efd1ba updates iostream unit tests 2013-03-17 21:48:43 -05:00
Peter Thorson 16c7d42bed adds boost_system for mutex dependency 2013-03-17 21:46:12 -05:00
Peter Thorson 3822384105 testing new scons g++ config 2013-03-17 21:43:12 -05:00
Peter Thorson f3810fa45e testing with regex common header 2013-03-17 21:41:09 -05:00
Peter Thorson a547ee5a7a adds logging of connection opening results 2013-03-17 20:13:51 -05:00
Peter Thorson 0236f0c722 adds lots of iostream transport unit tests 2013-03-17 18:28:46 -05:00
Peter Thorson d5d5a3330d adds logger test case with real concurrency primitives 2013-03-17 18:28:29 -05:00
Peter Thorson caa828defe adds lots of documentation to iostream transport 2013-03-17 18:27:54 -05:00
Peter Thorson 51633781e3 fixes missing dependency on the logger 2013-03-17 18:27:42 -05:00
Peter Thorson c73df1f3b5 fixes uninitialized m_output_stream variable 2013-03-17 18:27:21 -05:00
Peter Thorson 8e6bdfe42f impliments get_remote_endpoint for iostream transport 2013-03-17 18:26:46 -05:00
Peter Thorson 8e2b424887 fixes handling for zero length reads and reads to zero length buffers 2013-03-17 18:26:16 -05:00
Peter Thorson 940108b2a8 fixes a bug in scatter gather writes with lengths other than 1 2013-03-17 18:25:35 -05:00
Peter Thorson 2584aed3d9 Fixes a bug in back to back iostream reads 2013-03-17 18:24:36 -05:00
Peter Thorson 727328cc9a updates output_stream member variable name to be consistent with WebSocket++ style 2013-03-17 18:24:07 -05:00
Peter Thorson f7c36c46e9 adds new unit testing utility error code 2013-03-17 18:22:27 -05:00
Peter Thorson 7db9817d20 adds more transport documentation 2013-03-17 18:22:02 -05:00
Peter Thorson 56f5472c88 terminate test 2013-03-16 20:59:03 -05:00
Peter Thorson f51a650027 Enables C++11 STL random usage on g++ 2013-03-16 09:02:39 -05:00
Peter Thorson 8e23bbf5b2 adds missing iostream include to random test 2013-03-15 07:56:55 -05:00
Peter Thorson 54ef4db3a1 adds example code for enriched and associative storage 2013-03-10 13:22:53 -05:00
Peter Thorson b3a07d0978 adds overridable connection base class 2013-03-10 08:47:58 -05:00
Peter Thorson 117a76f1f9 updates gitignore 2013-03-08 08:47:45 -06:00
Peter Thorson e5758d7b58 adds code from some of the manual examples 2013-03-08 08:47:28 -06:00
Peter Thorson 213451370d adds an overload of get_con_from_hdl that throws 2013-03-08 08:45:40 -06:00
Peter Thorson 6f34b0f062 adds functional support for std::ref 2013-03-08 08:44:55 -06:00
Peter Thorson ee847e37fb adds more tests for endpoint base classes 2013-03-06 09:10:05 -06:00
Peter Thorson c7e0647626 fixes typo 2013-03-06 08:33:20 -06:00
Peter Thorson 37b1c65904 impliments a user overridable endpoint base class and associated tests 2013-03-06 08:33:11 -06:00
Peter Thorson 40abb49483 adds tests related to request bodies 2013-03-03 17:34:53 -06:00
Peter Thorson a6ce671c56 moves body to parser rather than response since requests can have bodies too. 2013-03-03 17:34:41 -06:00
Peter Thorson aaff9a5f49 makes none the default RNG to avoid requiring random_device in server configs 2013-03-03 17:34:03 -06:00
Peter Thorson 14b2012328 Adds RNG unit tests 2013-03-02 20:47:30 -06:00
Peter Thorson 8b7fe18a85 updates config to add RNG policy 2013-03-02 20:47:23 -06:00
Peter Thorson fbe991d9c2 updates boost random headers 2013-03-02 20:47:11 -06:00
Peter Thorson b373a388e7 completes int_generator policies 2013-03-02 20:47:01 -06:00
Peter Thorson ea4e66e14b additional iostream thread safety 2013-03-02 20:46:36 -06:00
Peter Thorson 8ec273e363 makes a cast explicit 2013-03-02 12:21:27 -06:00
Peter Thorson 45b3ed51ff moves some typedefs to public from protected 2013-03-01 17:28:12 -06:00
Peter Thorson 447c398479 fixes issue where close handler would be called twice 2013-02-24 16:29:53 -06:00
Peter Thorson ce95137ef5 Removes more implicit casts 2013-02-17 07:44:41 -06:00
Peter Thorson 78b52be803 removes force casting from int to bool 2013-02-17 07:13:09 -06:00
Peter Thorson e4f6aafb04 fixes some more visual studio warnings 2013-02-16 12:48:07 -06:00
Peter Thorson 9e19765bdf Fixes MSVC++ C4800 error (converting char to bool) 2013-02-16 12:41:07 -06:00
Peter Thorson 5c01b272fe changes generic to general because generic is a reserved word in visual studio 2013-02-16 12:31:32 -06:00
Peter Thorson e0abafbd71 moves stdint header to common includes 2013-02-08 08:48:39 -06:00
Peter Thorson f529ff2fbc updates connection test build dependency 2013-02-08 08:43:55 -06:00
Peter Thorson ddfc0566f5 adds timer support 2013-02-02 13:10:06 -06:00
Peter Thorson faaa8eb03e initial work on timer support 2013-02-02 10:54:30 -06:00
Peter Thorson 7d76532165 adds some documentation examples 2013-02-02 10:54:30 -06:00
Peter Thorson 6861398648 adds lowercase synonyms for some constants 2013-02-02 10:54:30 -06:00
Peter Thorson 3a92ff981a Merge pull request #183 from eandre/experimental
Added missing 'inline' directives
2013-02-01 15:43:45 -08:00
Peter Thorson 780847bf43 cleans up handle_accept error paths 2013-02-01 09:11:43 -06:00
Peter Thorson 99bc0abffc updates write_flag code to be robust and exception/thread safe 2013-02-01 08:59:57 -06:00
Peter Thorson 8d050767e1 fixes warning 2013-02-01 08:59:35 -06:00
Peter Thorson 45813db04d simplifies sending close frames 2013-02-01 07:55:42 -06:00
Peter Thorson 5ea7ee328e adds state check to connection::close 2013-02-01 07:50:13 -06:00
Peter Thorson 662b4333aa updates close adaptor to proper connection interface 2013-02-01 07:50:03 -06:00
Peter Thorson d0cbb07d5c adds documentation and adaptors for connection::close 2013-02-01 07:41:04 -06:00
Peter Thorson b999051959 adds raw array based send adaptors to endpoint 2013-02-01 07:26:20 -06:00
Peter Thorson 7ffbe8bfd8 moves bad_connection error handling into get_con_from_hdl 2013-02-01 07:25:44 -06:00
Peter Thorson 30134f8545 moves adaptor functions into endpoint_impl 2013-02-01 07:19:11 -06:00
Peter Thorson 30412282ee Updates constructor field order 2013-02-01 07:18:06 -06:00
Peter Thorson aa9644f2a8 fixes typo 2013-02-01 07:13:09 -06:00
Peter Thorson 1bfe86d795 Adds raw array send method to connection 2013-02-01 07:09:02 -06:00
Peter Thorson 5b9afc0309 updates message buffer's set and append payload methods to allow both std::string and raw array input 2013-02-01 07:02:38 -06:00
Peter Thorson 4063440895 temporary logging test changes 2013-01-31 20:30:02 -06:00
Peter Thorson c88cdaf2f4 updates buffer size to a more efficient default 2013-01-31 20:29:08 -06:00
Peter Thorson 6925a68f95 temporary fix for outgoing frame corruption issue #references 179 2013-01-31 08:41:37 -06:00
Peter Thorson 4928f84feb removes un-thread-safe access to cout 2013-01-31 08:40:46 -06:00
Peter Thorson b4903dad0b adds an application level logging level 2013-01-31 08:40:16 -06:00
Peter Thorson 7fe9eb592f refines endpoint logging interface 2013-01-31 08:39:57 -06:00
Peter Thorson 080fd42a0b updates readme 2013-01-27 10:39:55 -06:00
Peter Thorson 1979502a05 adds default logging settings to echo_server and catches more setup exceptions 2013-01-27 10:37:47 -06:00
Peter Thorson fa85811c07 adds some logger tests 2013-01-27 10:37:14 -06:00
Peter Thorson c83f8f485a adds pass through logging adaptor to endpoint 2013-01-27 10:36:19 -06:00
Peter Thorson 0bb60df7fc adds a typedef for logging levels 2013-01-27 10:35:57 -06:00
Peter Thorson 375108aabf Switches cout based logging to logging policy 2013-01-27 08:20:08 -06:00
Peter Thorson 37b6b5fb3c updates tests for logger 2013-01-27 08:19:32 -06:00
Peter Thorson 389e5925d7 splits asio/asio_no_tls up a bit better, adds logging information to configs 2013-01-27 08:19:19 -06:00
Peter Thorson a5d3555f96 whitespace 2013-01-27 08:18:10 -06:00
Andre Eriksson d6edaac02b Added missing 'inline' directives 2013-01-26 09:12:38 +01:00
Peter Thorson 6ab39622e5 adds basic logger class, with tests, and updates configs to include it 2013-01-20 20:24:26 -06:00
Peter Thorson 278909aad6 adds common chrono header 2013-01-20 20:23:47 -06:00
Peter Thorson 295c51c2c5 updates copyright year 2013-01-20 20:23:37 -06:00
Peter Thorson 9b142e3edc adds common/thread header and updates concurrency policies to use it 2013-01-20 20:23:22 -06:00
Peter Thorson 18fef37837 additional work on the broadcast server example 2013-01-20 14:31:54 -06:00
Peter Thorson 44e47267e9 initial work on broadcast_server example 2013-01-20 11:05:30 -06:00
Peter Thorson 290b719048 inlines appropriate functions to work when included in multiple translation units. fixes #178 2013-01-20 09:02:17 -06:00
Peter Thorson 7b2ed75e46 moves network related utility functions into network header 2013-01-20 08:57:51 -06:00
Peter Thorson c76771b323 splits connection test into two translation units 2013-01-20 08:56:38 -06:00
Peter Thorson 9a7631b2da updates endpoint concurrency features 2013-01-20 08:56:11 -06:00
Peter Thorson eb1603177f updates close to include network header 2013-01-10 08:47:16 -06:00
Peter Thorson 931bd92782 adds a common header to organize platform specific network related includes 2013-01-10 08:45:51 -06:00
Peter Thorson 8dbcb79eb5 Update BOOSTROOT build env variable to have consistant naming 2013-01-10 07:08:03 -06:00
Peter Thorson eb706ab7bd disable dev test application by default since it has some extra unwanted dependencies 2013-01-10 07:07:38 -06:00
Peter Thorson e1a333e4f3 include missing header 2013-01-10 07:07:08 -06:00
Peter Thorson cbaee8b4d5 notes about initialization 2013-01-09 09:15:26 -06:00
Peter Thorson f0006864dc updates readme 2013-01-09 09:14:53 -06:00
Peter Thorson 5d7e32fa10 rearranges some stuff 2013-01-09 08:05:43 -06:00
Peter Thorson 43ad5ee342 adds endpoint initialization tests 2013-01-09 07:20:35 -06:00
Peter Thorson 58dd020753 simplifies init_asio signature 2013-01-09 07:20:21 -06:00
Peter Thorson 4edc446b01 fixes a bug cleaning up external io_services 2013-01-09 07:20:05 -06:00
Peter Thorson 107b60dd01 adds endpoint unit test suite 2013-01-09 07:07:01 -06:00
Peter Thorson 7ab2d2c937 removed unnecessary typenames 2013-01-09 07:06:50 -06:00
Peter Thorson 1b83d5e855 better debug printing 2013-01-09 07:06:38 -06:00
Peter Thorson 0e6e41d1c4 adds some more status info to the readme 2013-01-09 06:15:04 -06:00
Peter Thorson a81a266c53 updates TLS code to new handler system 2013-01-09 06:14:39 -06:00
Peter Thorson a3e2e31e91 removes more dead code 2013-01-08 07:49:34 -06:00
Peter Thorson 4f914f8477 updates tests and echo server to new handler interface 2013-01-08 07:48:32 -06:00
Peter Thorson b315f9f684 adds send adaptor functions to endpoints 2013-01-08 07:47:59 -06:00
Peter Thorson a3acc4a1cf removes all old style handler code 2013-01-08 06:43:47 -06:00
Peter Thorson 31cc4af4f4 cleanup 2013-01-08 06:33:06 -06:00
Peter Thorson ef8898afef adds support for message_handler 2013-01-08 06:33:02 -06:00
Peter Thorson 8df37fffbc Updates on_http and validate handlers to use new handler interface 2013-01-07 17:14:29 -06:00
Peter Thorson e7b87e5d54 Updates on_ping, on_pong, and on_pong_timeout handlers to new interface 2013-01-07 16:53:14 -06:00
Peter Thorson 235b567b59 Updates on_close and on_fail to use new handler style 2013-01-07 12:45:09 -06:00
Peter Thorson ebfb8b8e2f Removes handler_interface from all transport code 2013-01-07 12:30:41 -06:00
Peter Thorson 6a4173578e Removes handler_interface types from socket components 2013-01-07 12:27:17 -06:00
Peter Thorson fe582e90e0 updates connection and endpoint to use new component styles 2013-01-07 12:23:21 -06:00
Peter Thorson 8b890d755b Updates asio transport components to new styles 2013-01-07 12:22:46 -06:00
Peter Thorson 052abf06ad Updates asio socket components to new styles 2013-01-07 12:22:16 -06:00
Peter Thorson e339e0f5c6 Updates server role with new component style 2013-01-07 12:21:28 -06:00
Peter Thorson 7aa7f3af80 Updates iostream transport to new component style 2013-01-07 12:20:41 -06:00
Peter Thorson f9c62ee778 Updates configs for new socket API 2013-01-07 12:18:37 -06:00
Peter Thorson f5d4cbe143 updates asio on_tcp_init callback to new api 2013-01-06 10:10:35 -06:00
Peter Thorson ce7b09767a adds documentation 2013-01-06 10:10:18 -06:00
Peter Thorson 2ad049055c updates echo_server to use new interrupt API 2013-01-06 09:59:55 -06:00
Peter Thorson 05f9faebf5 updates interrupt functionality to latest API spec 2013-01-06 09:59:38 -06:00
Peter Thorson 5949c58d2e updates transport accept loop to use connection_hdl and not be a template function 2013-01-06 09:19:08 -06:00
Peter Thorson a48c788ecc asio transport connection now recieves connection hdl 2013-01-06 09:17:09 -06:00
Peter Thorson 9ca476ae22 iostream connection now receives connection hdl 2013-01-06 09:16:49 -06:00
Peter Thorson 7bbfaa78bc connection forwards handle to transport 2013-01-06 09:16:11 -06:00
Peter Thorson db6b32b90b const correctness 2013-01-06 09:15:55 -06:00
Peter Thorson 77422dec25 better qualifies subclass typedefs 2013-01-06 09:15:20 -06:00
Peter Thorson d705a805eb adds ability to retrieve connection_hdl and some docs 2013-01-06 08:53:58 -06:00
Peter Thorson 9253e4fca2 adds a pointer type 2013-01-06 08:50:25 -06:00
Peter Thorson b5a5fd6fe3 adds a pointer type 2013-01-06 08:50:15 -06:00
Peter Thorson 266ceafa26 connects interrupt's error handling 2013-01-06 08:49:55 -06:00
Peter Thorson 21eb1bbd35 adds a convenience function to retrieve connection pointers from handles 2013-01-06 08:49:36 -06:00
Peter Thorson 853c46a0f5 clarifies source of request_type redefinition 2013-01-06 06:45:35 -06:00
Peter Thorson a6002daddd fixes security category make_error_code 2013-01-06 06:43:20 -06:00
Peter Thorson 448588ac5c fixes missing return value 2013-01-06 06:42:55 -06:00
Peter Thorson 2af6ccb7a7 Adds initial readme 2013-01-06 06:12:59 -06:00
Peter Thorson f10f8a4ce0 Initial commit from private 0.3 repository 2013-01-06 06:09:15 -06:00
Peter Thorson 5809440f1a Updates multithreaded non-forked listen methods to not prematurely close the endpoint. references #168 2013-01-04 07:06:54 -06:00
Peter Thorson 4799525445 removes endpoint state change that breaks multi-threaded servers references #168 2013-01-04 06:28:44 -06:00
Peter Thorson 0c4d239aeb fixes formatting 2012-12-19 06:45:46 -06:00
Peter Thorson 43970572f5 version bump 2012-12-19 06:36:28 -06:00
Peter Thorson 6a1dccc8cb corrects an infinite loop when the acceptor is closed in thread pool mode references #168 2012-12-19 06:26:28 -06:00
Peter Thorson 6aa11a7fac Updates user agent/version string 2012-12-11 07:45:20 -06:00
Peter Thorson 0318700c00 m_requested_subprotocols wasn't getting populated. fixes #155
Thank you to robagar for finding this bug and jeffjcrowe for supplying
a patch
2012-12-11 07:07:25 -06:00
Peter Thorson 27a6d6f4d3 Close acceptor on stop_listen. fixes #161 2012-12-11 06:53:43 -06:00
Peter Thorson ce1c1d3a76 removes unnecessary check fixes #163 2012-12-11 06:42:50 -06:00
Peter Thorson 1c8ba9954e Adjusts ordering guarantees on message sending references #149 2012-10-12 07:56:05 -05:00
Peter Thorson 52ce31bea4 updates the order of endpoint and handler construction #references 147 2012-10-12 06:36:23 -05:00
Peter Thorson 47a3c060ee Revert "Fix Compiler Warning on using std::copy: no point using STL routines inside low-level C-style code"
This reverts commit 5dfe48b043.
2012-10-12 06:31:18 -05:00
Peter Thorson d80d9afd88 preliminary work on a fix to the ARM aliasing issues 2012-10-12 06:29:42 -05:00
Peter Thorson 25322aac0d adds missing virtual destructor 2012-10-12 06:29:42 -05:00
Peter Thorson 10ac9c41ec removes unused varaible from wsperf 2012-10-12 06:29:42 -05:00
Peter Thorson 492ada4788 updates SConstruct compile flags for posix and darwin 2012-10-12 06:29:41 -05:00
Peter Thorson b73f1526b6 Merge pull request #148 from NNemec/master
Various small changes of general interest
2012-10-12 04:29:12 -07:00
Norbert Nemec 34a10b0916 split server::listen interface into start_listen and stop_listen, allowing the controlling thread to continue running asynchronously. (Legacy interface provided) 2012-10-09 15:08:25 +02:00
Norbert Nemec db0a43a228 Disable warning C4355 for plain.hpp similar to server.hpp (beware: this hides a real design problem) 2012-10-09 14:06:20 +02:00
Norbert Nemec dbdb150021 clarify interface by correct argument names 2012-10-09 14:00:07 +02:00
Norbert Nemec 5dfe48b043 Fix Compiler Warning on using std::copy: no point using STL routines inside low-level C-style code 2012-10-09 13:59:52 +02:00
Norbert Nemec 3e3b5a0bb8 fix compiler issue 2012-10-09 12:15:17 +02:00
Norbert Nemec 54b1931963 Fix compiler issue: boost/cstdint.hpp contains the types inside boost:: namespace. <stdint.h> should be available by default. vcpp2008 has its own workaround. 2012-10-09 12:15:03 +02:00
Norbert Nemec c2f83814dc Update vcpp2008 project files and use common.vsprops for configuring external dependencies (i.e. boost) 2012-10-09 12:11:01 +02:00
Peter Thorson dd9899c34b Adds virtual destructors to handler interfaces fixes #136 2012-09-24 07:47:14 -05:00
Peter Thorson a17a27dd5c updates set_handler to by synchronous fixes #139 2012-09-24 07:41:25 -05:00
Peter Thorson 546846af19 Merge pull request #141 from 422053362/patch-1
Workaround for windows min and max macros with std::min and std::max
2012-09-24 05:12:01 -07:00
422053362 12245fd745 Update src/roles/client.hpp
sometimes it cause error。
 I have check the function "uniform_int_distribution" ,
 the right way to construct is
 boost::random::uniform_int_distribution<>(
                (std::numeric_limits<int32_t>::min)(),
                (std::numeric_limits<int32_t>::max)()
             )
not 
 boost::random::uniform_int_distribution<>(
                std::numeric_limits<int32_t>::min(),
                std::numeric_limits<int32_t>::max()
             )
maybe sometimes the second way would not cause error,but sometimes it dose.so I modified.
2012-09-23 05:33:57 +08:00
Peter Thorson 16aaa00a1c Fixes an issue where http handler callback is called before building the URI #references #118
Thank you ShuminHuang for filing this bug
2012-08-04 09:59:41 -05:00
Peter Thorson 4b3ca1911b Merge pull request #131 from jrosser/fixes
Small fixes for compiling on Ubuntu 12.04
2012-08-04 07:44:12 -07:00
Peter Thorson 925b4cdd68 Merge pull request #124 from oberstet/master
minor thing
2012-08-04 07:36:10 -07:00
Jonathan Rosser 6f0722b04e fix build of fuzzing_client
this seems fairly fundamental - does nothing else use this and fail?
2012-07-31 13:01:04 +01:00
Jonathan Rosser 3ecec05364 fix stress_client warning and compile error 2012-07-31 13:00:53 +01:00
Jonathan Rosser a0040da1d7 add another missing linkage against pthreads 2012-07-31 09:44:27 +01:00
Jonathan Rosser 159b9d3a88 fix missing boost_thread from some examples 2012-07-29 08:47:16 +01:00
Jonathan Rosser b7009335fe fix usage of C99 macros in C++ 2012-07-26 11:29:10 +01:00
Tobias Oberstein 44bacdb323 does away with VC++ warning: C4309 - truncation of constant value 2012-07-18 14:09:39 +02:00
Peter Thorson 3208b1b493 fixes telemetry server bug references #121 2012-07-11 08:47:45 -05:00
Peter Thorson 1f8113bbd6 adds telemetry server example 2012-07-11 08:20:37 -05:00
Peter Thorson 87d76a3995 Fixes a frame read issue with hybi00 references #101 2012-07-10 07:25:27 -05:00
Peter Thorson 84e021e679 updates makefile for wsperf stress test 2012-06-28 06:52:11 -05:00
Peter Thorson 8d9f55ad23 Merge pull request #117 from dasty/master
Just fixing compilation issue for people who use makefile
2012-06-28 04:39:15 -07:00
Peter Thorson 9716a2269c Merge pull request #113 from pmarques/master
Compiler error due to ambiguous methods resolution
2012-06-28 04:36:40 -07:00
Radek Dostal 125142a7d1 $(CXX) linker should not be run for build of object files
Signed-off-by: Radek Dostal <rd@radekdostal.com>
2012-06-18 18:57:51 +02:00
Peter Thorson f78b9df4ad disable file descriptor limits by default to not confuse windows 2012-06-07 13:46:18 -05:00
Peter Thorson 241a28cbd7 javascript reference clients for message_test and stress_test 2012-06-07 13:44:56 -05:00
Peter Thorson 61be3c182c stress_test now supports message sending & stats 2012-06-07 13:44:56 -05:00
Peter Thorson a3b7546d65 Merge pull request #116 from oberstet/master
make win build and warn free
2012-06-07 05:57:20 -07:00
Peter Thorson 0cd1c58505 stress_test parameter parsing 2012-06-07 06:09:24 -05:00
Peter Thorson 674042f576 preliminary support for thousands of connections on darwin and linux 2012-06-07 06:09:02 -05:00
Peter Thorson 0b10e9c0a3 adds extract string support for wscmd 2012-06-07 06:07:42 -05:00
Tobias Oberstein 9838895d39 slight adjust 2012-06-07 12:55:07 +02:00
Tobias Oberstein 19173e9584 some minor things (make win build warn free) 2012-06-07 12:49:55 +02:00
Peter Thorson b58cf53353 some windows fixes 2012-06-05 08:39:08 -05:00
Peter Thorson 2d12256c7c adds handshake delay and test doneness check 2012-06-05 08:26:06 -05:00
Peter Thorson 1d3942622a this can cause crazy runaway reconnects, need to rethink 2012-06-05 08:25:52 -05:00
Peter Thorson 002e75891e adds preliminary stress_test mode to wsperf 2012-06-04 08:47:37 -05:00
Peter Thorson 2f6565565b adds client on_handshake_init callback 2012-06-04 08:47:37 -05:00
Peter Thorson 232fd1ebf6 Merge pull request #115 from beeftaco/master
Updated project and solution files for better Windows compatibility
2012-05-29 04:06:41 -07:00
beeftaco 469c97c7d9 Updated compatibility for VS2010 2012-05-28 11:47:34 -07:00
Patrick F. Marques 8e091853cc Correction of compiler error due to ambiguous "call conversionS" 2012-05-03 10:40:57 +01:00
Peter Thorson 899b7e3bea defines CPP11 friend fix for Visual Studio 2012-04-22 15:22:40 -05:00
Peter Thorson 9ba194a7f9 fixes #103 2012-04-13 08:47:48 -05:00
Peter Thorson e928f4a566 adds preliminary machine readable connection failure information 2012-04-13 08:34:22 -05:00
Peter Thorson 31a9f9a9bc potential fixes for hixie76 handshakes, references #101 2012-04-13 07:38:15 -05:00
Peter Thorson 7875f03f76 adds WS handshake timeout 2012-04-13 07:36:00 -05:00
Peter Thorson 419178dead adds hook for on_handshake_init 2012-04-13 07:35:29 -05:00
Peter Thorson a4bca13636 generic timeout support 2012-04-13 07:34:50 -05:00
Peter Thorson 8d846000bf adds on_tcp_init hook and TLS handshake timeout 2012-04-13 07:34:22 -05:00
Peter Thorson dc3be3d658 adds on_tcp_init hook 2012-04-13 07:34:11 -05:00
Peter Thorson 75ef3defe9 adds header needed on unix 2012-04-13 07:33:52 -05:00
Peter Thorson 0eedb6e8b6 moves JS libraries into "vendor" folder to escape Linguist 2012-04-13 07:33:30 -05:00
Peter Thorson 04f8413f7d Merge pull request #104 from jdale88/master
Compiler fixes for VS2010
2012-04-12 19:25:01 -07:00
Jamie Dale 42afb69ede Compiler fixes for VS2010.
This fixes some errors caused by Windows defining things like min and max, as well as a number of warnings about type conversion, unused parameters, inability to generate assignment operators, and constant conditions.

All type conversions were assumed to be intentional, and static_casts have been added to remove the compiler warnings.

The server code should now build cleanly with level 4 warnings enabled (as used in my project), and the client code should build cleanly with level 3 warnings enabled (as used by the WebSocket++ projects).
2012-04-12 19:31:12 +01:00
Peter Thorson af23ead5fc removes more duplicate javascript libraries 2012-04-10 09:09:07 -05:00
Peter Thorson dc1e432cdf removes second bundled copy of slot 2012-04-10 09:03:11 -05:00
Peter Thorson 7c4c359ef9 disable experimental support for client thread pool by default 2012-04-10 08:54:51 -05:00
Peter Thorson 1512598e3f logging robustness changes 2012-04-10 08:26:23 -05:00
Peter Thorson 9bc3220b5e message processor performance improvements 2012-04-10 08:25:46 -05:00
Peter Thorson 8129787625 to_hex for char* 2012-04-10 08:24:54 -05:00
Peter Thorson 14802c7afc wsperf logging and preliminary stress_test work 2012-04-10 08:24:39 -05:00
Peter Thorson 64156eff9f updates build system files 2012-04-10 08:22:30 -05:00
Peter Thorson 4e7b899dc7 new wsperf module files 2012-04-10 08:21:57 -05:00
Peter Thorson ea19f1e501 masking utility functions and unit tests 2012-04-10 08:21:35 -05:00
Peter Thorson f3fc8a2466 cleans up and documents some hixie 76 issues references #101 2012-04-07 10:15:28 -05:00
Peter Thorson 6c9d814392 fixes #78 2012-04-07 10:06:36 -05:00
Peter Thorson eb79122da9 update Xcode project 2012-04-07 10:03:32 -05:00
Peter Thorson bb2154613c removes some debug code 2012-04-07 10:02:53 -05:00
Peter Thorson 5f3fbc9593 Merge branch 'master' of github.com:zaphoyd/websocketpp 2012-03-28 09:51:05 -05:00
Peter Thorson b2f57039ae fixes user agent header typo, fixes #100 2012-03-28 09:50:26 -05:00
Peter Thorson 0c90670176 fixes wsperf build on g++ 4.6 2012-03-27 08:15:41 -05:00
Peter Thorson b8ddddfe01 masking optimizations off by default 2012-03-25 14:33:00 -05:00
Peter Thorson 0f95459ac4 preliminary masking code performance improvements 2012-03-25 08:40:29 -05:00
Peter Thorson 368a0f3726 fixes mutex support in const methods 2012-03-25 08:39:39 -05:00
Peter Thorson 3017830e77 clean up legacy code 2012-03-23 13:44:24 -05:00
Peter Thorson edf244daf7 better detached connection error handling 2012-03-23 13:44:03 -05:00
Peter Thorson 2109723b34 adds thread pool support to concurrent_server example 2012-03-21 22:46:38 -06:00
Peter Thorson 9348aa4c21 adds thread pool support to server 2012-03-21 22:37:04 -06:00
Peter Thorson 6ca0b49ae0 more concurrency cleanup, misc features 2012-03-21 21:57:58 -06:00
Peter Thorson 517852cd95 adds silent close option 2012-03-21 21:57:20 -06:00
Peter Thorson d20a2f6fef hybi processor silent close frame 2012-03-21 21:56:51 -06:00
Peter Thorson 461fe64242 async handle_read_frame in server 2012-03-21 21:56:23 -06:00
Peter Thorson 892fdd2456 updates defaults 2012-03-21 21:56:01 -06:00
Peter Thorson 3cef677c31 docs and concurrency clean up 2012-03-19 16:20:27 -06:00
Peter Thorson 2f6a014a2e docs and cleanup 2012-03-19 16:19:44 -06:00
Peter Thorson 59efe59466 wrap async calls with strand 2012-03-19 15:53:49 -06:00
Peter Thorson 9d221c6a84 updates some todos 2012-03-19 15:53:17 -06:00
Peter Thorson 60c2f8efb2 lots of new constants 2012-03-19 15:50:11 -06:00
Peter Thorson b5cd8488ce update chat client for new API 2012-03-19 15:49:51 -06:00
Peter Thorson 8e73e436d0 WS++ very fast fail on utf8 fixes 2012-03-18 16:41:54 -05:00
Peter Thorson 14562aa8bc enable angle by default 2012-03-18 16:41:30 -05:00
Peter Thorson ae12a9ee52 C++ style copy and set 2012-03-18 14:33:13 -05:00
Peter Thorson 41cd2ac01e Merge pull request #95 from blindmatrix/76296fe2dd49c55d85f818005ea9bb6901807c79
Fixed compile-time warnings
2012-03-18 11:42:21 -07:00
Sven Almgren 76296fe2dd Fixed broken conversion 2012-03-15 16:15:41 +01:00
Sven Almgren 9cdc8e7009 Merge branch 'master' of https://github.com/zaphoyd/websocketpp 2012-03-15 15:15:50 +01:00
Sven Almgren 6fabf34630 Removed some nonstrict-alias code 2012-03-15 15:15:19 +01:00
Peter Thorson f6fd0f4fb2 Merge pull request #93 from oberstet/master
Build fixes
2012-03-15 06:33:06 -07:00
Tobias Oberstein 09c541185d disable TLS build on Win .. needs OpenSSL dev .. 2012-03-15 14:27:25 +01:00
Tobias Oberstein c6bb4912b2 fix scons build 2012-03-15 14:11:21 +01:00
Peter Thorson 3994731df8 Merge branch 'master' of github.com:zaphoyd/websocketpp 2012-03-15 07:37:31 -05:00
Peter Thorson 6b32481a87 make static library default 2012-03-15 07:36:29 -05:00
Peter Thorson 2fa84a07f0 Merge pull request #92 from blindmatrix/master
Removed extra comma in header (and more stuff)
2012-03-15 05:36:08 -07:00
Sven Almgren 1a0796d315 Removed duplicate variable in assignment (m_state = m_state = X) 2012-03-15 12:57:34 +01:00
Sven Almgren 002b8a2c35 Removed extra comma, as -pedantic complains 2012-03-15 11:56:34 +01:00
Peter Thorson 26462c17d8 new makefile bug fix for static builds 2012-03-14 07:33:11 -05:00
Peter Thorson 4bf1d63741 Merge pull request #89 from blindmatrix/policy-refactor
centralized makefiles for examples
2012-03-14 05:26:59 -07:00
Sven Almgren 36e76ac246 Merged upstream and resolved confilicts 2012-03-14 13:15:01 +01:00
Sven Almgren f085cc63b6 Centralized makefiles for examples 2012-03-14 12:52:55 +01:00
Sven Almgren 844f34bb3a Removed binary from source tree 2012-03-14 12:51:06 +01:00
Peter Thorson 3f7664ab97 Merge pull request #87 from blindmatrix/policy-refactor
Policy refactor: Updates to makefiles
2012-03-14 04:50:29 -07:00
Peter Thorson 35691eca17 adds more scons targets 2012-03-14 06:39:18 -05:00
Sven Almgren 6d206c0e9f Hide generated shared SO files 2012-03-14 12:36:46 +01:00
Sven Almgren 5b9cab14ff Removed quotes from SHARED and BUILD_TYPE defaults 2012-03-14 12:33:51 +01:00
Sven Almgren b985f5aa4b Fixed if-statement for running ldconfig on newer Ubuntu 2012-03-14 12:31:58 +01:00
Peter Thorson 046c2dea91 scons build supports echo_client, chat_server, chat_client 2012-03-14 06:28:10 -05:00
Peter Thorson 6471b95a40 Xcode project update 2012-03-14 06:27:34 -05:00
Peter Thorson 7fca59a99b fixes example server bugs and logging levels 2012-03-14 06:27:28 -05:00
Peter Thorson 576b6e43ad unix makefile updates 2012-03-14 06:27:10 -05:00
Peter Thorson 02dd3f8193 removes legacy files 2012-03-14 06:26:55 -05:00
Sven Almgren f9d21d80b6 Make sure lib-directory exists before copying files on install 2012-03-14 12:09:04 +01:00
Sven Almgren 3d2078c372 Added new variable to specify base of boost library (BOOST_PREFIX) 2012-03-14 11:59:13 +01:00
Peter Thorson a0eeb7fb71 removes legacy code 2012-03-14 05:54:22 -05:00
Peter Thorson 8e2c82e098 connection destructor fix 2012-03-12 10:48:18 -05:00
Peter Thorson f32ddff367 concurrency review part 1 2012-03-12 10:03:54 -05:00
Peter Thorson a3001a4c7c concurrency fixes 2012-03-11 20:42:22 -05:00
Peter Thorson 6380f56384 wsperf blocking mode 2012-03-11 17:02:14 -05:00
Peter Thorson cfc491ffce fixes some concurrency bugs 2012-03-11 13:19:53 -05:00
Peter Thorson a76e662192 reset request coordinator after connection failure 2012-03-11 12:44:38 -05:00
Peter Thorson 3c043a402f log level tweaks 2012-03-11 08:37:05 -05:00
Peter Thorson 294b416ec9 adds wsperf silent mode and client auto-reconnect 2012-03-11 08:26:34 -05:00
Peter Thorson 6e7589787b test_start message indicates which thread will run test 2012-03-11 08:05:14 -05:00
Peter Thorson 46c3a0b29d cleans up concurrent_handler adds num_workers to welcome 2012-03-11 07:55:20 -05:00
Peter Thorson 7c1f9d702e wsperf bug fixes 2012-03-10 18:39:57 -06:00
Peter Thorson 4903edbe30 wsperf won't set a timer when timeout=0 2012-03-10 16:19:37 -06:00
Peter Thorson 338ac2a574 updates wsperf to use library UA constant 2012-03-10 11:22:35 -06:00
Peter Thorson d1b552691a adds websocketpp::USER_AGENT constant 2012-03-10 11:22:25 -06:00
Peter Thorson cedfddd8ed updates wsperf.cfg with new options 2012-03-10 11:21:57 -06:00
Peter Thorson c0fc773071 adds welcome message to wsperf, lots of wsperf cleanup 2012-03-10 11:06:59 -06:00
Peter Thorson 5e8ed9f64f adds welcome message to wsperf, lots of wsperf cleanup 2012-03-10 11:06:22 -06:00
Peter Thorson 7042091a61 adds client mode and program options to wsperf 2012-03-10 09:10:01 -06:00
Peter Thorson 0360e6669a Merge branch 'policy-refactor' of github.com:zaphoyd/websocketpp into policy-refactor 2012-03-09 08:40:00 -06:00
Peter Thorson 6fd7a091e0 update chat_client to new API 2012-03-09 08:34:52 -06:00
Peter Thorson d21df34a87 fixes some client api issues 2012-03-09 08:32:40 -06:00
Peter Thorson ead6f8853c Merge pull request #81 from oberstet/policy-refactor2
Various build things
2012-03-08 10:45:37 -08:00
Tobias Oberstein 16a4ba98b4 refactor build for tree of scons makefiles, fix out of source build, correct target handling 2012-03-08 17:55:13 +01:00
Tobias Oberstein ae2dac32f0 make away warn 2012-03-08 17:15:37 +01:00
Tobias Oberstein 57630721f6 fix newlines at file ends, more aggressive optim. 2012-03-08 17:09:25 +01:00
Tobias Oberstein 48ac9e7042 use std::limits instead of macros, reorder includes, fix build 2012-03-08 16:55:23 +01:00
Tobias Oberstein 95a861c33b merge 2012-03-08 15:39:48 +01:00
Peter Thorson 1d9e0caeb6 adds namespace to network utilities, fixes #80 2012-03-08 08:29:50 -06:00
Peter Thorson a11e66d3f5 scons updates 2012-03-08 07:56:58 -06:00
Peter Thorson f506c185a8 fixes or silences some VCPP warnings 2012-03-08 07:55:41 -06:00
Tobias Oberstein 4c5421e3fa Basically rewrite SConstruct. VC++ builds without warns. Still needs variant dir / targets fixed. 2012-03-07 17:14:21 +01:00
Tobias Oberstein aac25f9532 Fix/silence warnings on vc++ 2012-03-07 15:58:02 +01:00
Tobias Oberstein f4b910d2c3 Merge remote branch 'peter/policy-refactor' into policy-refactor2 2012-03-07 15:47:50 +01:00
Peter Thorson b9fd0d99ad fixes data types for 32 bit systems 2012-03-07 08:37:12 -06:00
Tobias Oberstein 0832ab5e82 make vc build work again 2012-03-07 15:19:07 +01:00
Peter Thorson 69fb256087 some temporary fixes for windows builds 2012-03-07 08:13:46 -06:00
Peter Thorson 9512891f24 missed one ERROR rename in example 2012-03-07 08:01:19 -06:00
Peter Thorson edfb6308e6 updates vcpp2010 project 2012-03-07 08:01:03 -06:00
Peter Thorson accff169d8 experimental scons build file 2012-03-07 08:00:49 -06:00
Peter Thorson 8a5f84dd99 merges Tobias' statistics changes 2012-03-06 20:23:23 -06:00
Peter Thorson c3026e4e93 renames ERROR for better cross platform support 2012-03-06 19:04:43 -06:00
Peter Thorson 322f5116cb finishes wsperf refactoring 2012-03-06 18:55:05 -06:00
Peter Thorson fea76ad02c wsperf refactoring 2012-03-06 09:31:06 -06:00
Peter Thorson 301edcd948 wsperf bug fixes, adds Xcode target 2012-03-06 07:10:40 -06:00
Peter Thorson 133a313b02 better wsperf error message on connection fail 2012-03-05 11:40:49 -06:00
Peter Thorson 6e768d5816 client properly fires on_fail on connection failure references #69 2012-03-05 11:40:29 -06:00
Peter Thorson 0a386077dc removes binaries 2012-03-05 09:50:37 -06:00
Peter Thorson f7e7ad876b machine readable message types 2012-03-05 09:50:07 -06:00
Peter Thorson 3c433c4668 fixes wsperf avg and KBps starting values 2012-03-05 09:44:21 -06:00
Peter Thorson 623d9a1f98 corrected some stdint issues 2012-03-05 09:43:55 -06:00
Peter Thorson 827f8b657f includes token in output, fixes makefile 2012-03-05 09:24:02 -06:00
Peter Thorson 86eeba1124 slight optimization 2012-03-05 08:39:45 -06:00
Peter Thorson 5ff3a6292f adds preliminary wsperf example code 2012-03-05 08:34:42 -06:00
Peter Thorson 7c2e7d31c0 updates fuzzing_client makefile 2012-02-29 08:32:42 -06:00
Peter Thorson 363ff2f736 re-enables 9.1.x and 9.2.x tests in fuzzing client 2012-02-29 06:34:53 -06:00
Peter Thorson 93ac2e0a01 removes old api code 2012-02-29 06:33:43 -06:00
Peter Thorson 986905e80c chat server example updated to latest API 2012-02-24 08:03:47 -06:00
Peter Thorson 3ec229c223 minor echo server updates 2012-02-24 08:03:16 -06:00
Peter Thorson 2fba5ca478 uses union instead of reinterpret_cast 2012-02-24 07:36:29 -06:00
Peter Thorson f0365ba42e masking_key casting fix to resolve aliasing warnings #references 72 2012-02-20 06:56:41 -06:00
Peter Thorson c2cbe7110d newlines at end of all files #references #72 2012-02-20 06:41:09 -06:00
Peter Thorson 9e93420728 adds policy refactor headers to Makefile install. fixes #71 2012-02-20 06:34:53 -06:00
Peter Thorson e94825bb41 adjust listen locking, fixes #66 2012-02-13 07:06:15 -06:00
Peter Thorson 84884ff9cd fixes #55 2012-02-13 06:57:15 -06:00
Peter Thorson eec4882775 example updates 2012-02-13 06:56:58 -06:00
Peter Thorson 1d80eb6a88 ignore binaries 2012-02-13 06:56:47 -06:00
Peter Thorson 5239ce10dc ignore binaries 2012-02-03 19:54:53 -06:00
Peter Thorson 841a9d911d removes binaries 2012-02-03 19:54:15 -06:00
Peter Thorson 6793b61b5d refined and documented the concurrent_server example references #62 2012-02-03 19:53:25 -06:00
Peter Thorson 8271525d4b Adds concurrent_server example 2012-02-03 09:26:08 -06:00
Peter Thorson 5065ff2615 preliminary work on endpoint/connection concurrency support fixes #63 2012-02-03 09:25:56 -06:00
Peter Thorson 30455f985f begins work on endpoint state detection 2012-02-03 07:10:13 -06:00
Peter Thorson 65689610e7 client uses local resolver, fixes #60 2012-02-03 07:08:37 -06:00
Peter Thorson 4e021d1584 adds additional, more flexible, sever listen overloads fixes #59 2012-02-03 07:04:30 -06:00
Peter Thorson e43c6fa6ec adds SIZE_MAX definition 2012-02-02 07:16:14 -06:00
Peter Thorson 7e213d152e preliminary fix for async_write of stack data in server role. references #51 2012-01-31 10:45:29 -06:00
Peter Thorson 7ab7588c28 regex is no longer static, allows multi-threaded uri parsing. Fixes #54 2012-01-31 09:34:46 -06:00
Peter Thorson f1e66bd425 initial fixes for custom logging, references #56 2012-01-31 09:23:07 -06:00
Peter Thorson f501903d36 fixes shared library building 2012-01-31 09:17:57 -06:00
Peter Thorson cdb1beb947 fixes a crash when sending messages to hybi00 clients 2012-01-31 09:14:44 -06:00
Peter Thorson c4cab70702 libstdc++ and libc++ both work now 2012-01-31 09:14:00 -06:00
Peter Thorson 23a2747e04 experimental c++11 build settings 2012-01-31 09:13:02 -06:00
Peter Thorson 011a8f2ced additional experimental c++11 and libc++ support 2012-01-31 09:12:35 -06:00
Peter Thorson 6826a6665c debugging code 2012-01-25 08:56:45 -06:00
Peter Thorson 41412cebd9 some workarounds for a potential libc++ bug 2012-01-25 08:55:54 -06:00
Peter Thorson 67a2cbcbed fixes an async write from stack issue references #51 2012-01-25 08:11:46 -06:00
Peter Thorson 95da9c45c8 preliminary c++11 and libc++ build support 2012-01-25 08:10:37 -06:00
Peter Thorson 6377358c0b experimenting with weak pointers references #53 2012-01-24 21:28:47 -06:00
Peter Thorson f19d11a002 fixes character processing bug when using LLVM libc++ 2012-01-24 09:16:50 -06:00
Peter Thorson 4e6676ccca adds virtual destructors where appropriate 2012-01-24 09:08:54 -06:00
Peter Thorson 02b48a8dbb tweaks echo server default error logging 2012-01-20 08:02:03 -06:00
Peter Thorson 4b06fedd02 initial testing with shared_const_buffer references #51 2012-01-20 08:01:34 -06:00
Peter Thorson 45c67502cb typo 2012-01-20 08:00:37 -06:00
Peter Thorson 3d38726970 updates broadcast server example for new convenience headers 2012-01-20 08:00:10 -06:00
Peter Thorson 23a44d8112 client properly logs successful connections. 2012-01-20 07:23:25 -06:00
Peter Thorson 035e08de11 server error logging additions and fixes 2012-01-20 07:22:35 -06:00
Peter Thorson 6600f91bfa additional client cleanup 2012-01-20 06:41:01 -06:00
Peter Thorson a89cb776a1 improves client connect error handling. Fixes #52 2012-01-20 06:30:22 -06:00
Peter Thorson 100ba9825f updates 9.7/9.8 to better match AutoBahn 0.4.10 2012-01-19 09:30:31 -06:00
Peter Thorson bed6a41c50 updates makefiles for linux 2012-01-19 08:07:43 -06:00
Peter Thorson 64441f6487 adds fail notification to fuzzing client 2012-01-19 08:07:34 -06:00
Peter Thorson 15cd82d1b3 fuzzing client fully implements 9.1.x, 9.2.x, 9.7.x, 9.8.x 2012-01-18 18:19:18 -06:00
Peter Thorson 7cb31d1b2b bugfix 2012-01-18 13:55:52 -06:00
Peter Thorson 4beebe3bc1 fixes a windows/VC++ compile issue, references #50 2012-01-18 07:13:07 -06:00
Peter Thorson 048e57baa5 fixes a crash while closing all connections, references #50 2012-01-18 07:06:59 -06:00
Peter Thorson 5ec97306cf documentation updates 2012-01-17 19:40:47 -06:00
Peter Thorson 01516318d6 updates basic examples to use new convenience typedefs 2012-01-17 09:43:00 -06:00
Peter Thorson 63c50a520b adds convenience typedefs 2012-01-17 09:40:10 -06:00
Peter Thorson 72a80bd87b some fixes for windows compiling references #50 2012-01-17 09:38:51 -06:00
Peter Thorson 5b660a78e5 updates name of ssl.hpp to tls.hpp 2012-01-17 09:35:44 -06:00
Peter Thorson aaf2c7fa0a formatting and documentation fixes 2012-01-16 11:44:32 -06:00
Peter Thorson 656dbfa3ec sets listen limit back to non-debug value
High values leave the server open to DoS attacks.
2012-01-16 11:20:10 -06:00
Peter Thorson 609e6f3eaf better hixie 76 fix 2012-01-16 11:18:16 -06:00
Peter Thorson 4568ad8d40 fixes pixie 76 handshake bug 2012-01-16 11:15:16 -06:00
Peter Thorson 9d422107ab adjusts whitespace 2012-01-16 11:14:51 -06:00
Peter Thorson 2525de2545 changes for compiling on windows fixes #49 2012-01-14 08:23:50 -06:00
Peter Thorson d93eeabc4c updates fuzzing examples for latest policy-refactor build 2012-01-13 08:41:55 -06:00
Peter Thorson e8cd60e3a8 resolves member function name conflict 2012-01-13 08:41:43 -06:00
Peter Thorson a1b5c503b2 removes debugging statement 2012-01-13 08:41:21 -06:00
Peter Thorson befdd002d2 adds close_all(), run(), and stop() methods to endpoint
This is the beginning of more robust support for all of the io_service
operations, run, stop, reset that properly clean up existing
connections. close_all also allows the server to be shut down
gracefully.
2012-01-13 08:19:20 -06:00
Peter Thorson e4a97f6233 server will end accept loop when create_connection returns NULL 2012-01-13 08:17:42 -06:00
Peter Thorson 3523052529 server policy delegates calls to run to endpoint 2012-01-13 08:16:50 -06:00
Peter Thorson 5704270138 adds internal endpoint logging flag 2012-01-13 08:16:14 -06:00
Peter Thorson 6fc8c588ff calling close while a connection is connecting will now abort the connection 2012-01-13 08:15:58 -06:00
Peter Thorson a17a4deb4b normalizes whitespace and sets up gitattributes to preserve fixes #43 fixes #46 2012-01-12 09:57:06 -06:00
Peter Thorson 75a3f8b068 updates gitignore 2012-01-12 09:55:41 -06:00
Peter Thorson 38b5b561e7 cleans up example code 2012-01-11 17:34:23 -06:00
Peter Thorson 00d40215e2 are clear() and resize(0) different? 2012-01-11 12:31:00 -06:00
Peter Thorson c4ca07ace5 bug fixes #47 2012-01-11 12:30:42 -06:00
Peter Thorson 9de65a10d4 very simple speed testing harness 2012-01-11 12:20:51 -06:00
Peter Thorson 1c0e1b0d2b better IPv6 literal URI parsing 2012-01-11 12:20:12 -06:00
Peter Thorson 69716bf4cd ignore binaries 2012-01-11 12:19:33 -06:00
Peter Thorson cd60832468 better IPv6 literal parsing tests 2012-01-11 12:19:20 -06:00
Peter Thorson 0e92bb207a ipv6 and uri parking fixes 2012-01-11 10:12:57 -06:00
Peter Thorson aaf5f51c35 exposes is_server through connection objects 2012-01-08 20:21:47 -06:00
Peter Thorson 83eaf70f57 whitespace issue 2012-01-08 20:21:29 -06:00
Peter Thorson a53a5e3a10 bug fix and process frame api simplification 2012-01-08 20:20:53 -06:00
Peter Thorson 1ecf0a2e6a payload valuation and gcc warning fixes 2012-01-08 20:20:17 -06:00
Peter Thorson 7ef6ea4ee3 updates connection to use control message pool 2012-01-08 20:19:41 -06:00
Peter Thorson 76fc0d6c6f adds a separate message pool for control messages 2012-01-08 20:18:52 -06:00
Peter Thorson 548ea142ff adds to_hex debug utility function 2012-01-08 20:18:24 -06:00
Peter Thorson 12bc3432f4 adds a generic exception class for application errors 2012-01-08 20:17:40 -06:00
Peter Thorson eb88c53d81 updates API version that the stress client uses 2012-01-08 20:17:11 -06:00
Peter Thorson 992456ae42 updates API version used by echo client example 2012-01-08 20:16:52 -06:00
Peter Thorson f6b68fe431 updates API version used by broadcast server example 2012-01-08 20:16:39 -06:00
Peter Thorson 14ada3a3a3 cleans up debugging code 2012-01-06 17:08:59 -06:00
Peter Thorson 93efa1ae97 write queue passes autobahn tests 2012-01-06 15:20:08 -06:00
Peter Thorson 50abd0b426 lots of bug fixes 2012-01-06 12:53:46 -06:00
Peter Thorson fe7a51bb32 intrusive pointer test 2012-01-06 09:35:02 -06:00
Peter Thorson fa7cd63706 work on write queue/flow control 2012-01-03 06:22:42 -06:00
Peter Thorson 3ff8775c1c updates broadcast admn. adds asks, wscmd support 2011-12-28 08:59:25 -06:00
Peter Thorson 17b779a1c4 updates stress client to use wscmd instead on json 2011-12-28 08:58:38 -06:00
Peter Thorson 28c32cf3cf send a scatter gather buffer list instead of string 2011-12-28 08:58:10 -06:00
Peter Thorson 9145a43e47 tabs to spaces 2011-12-28 07:52:10 -06:00
Peter Thorson a848d1dde5 more unfinished header writing work 2011-12-26 11:45:41 -06:00
Peter Thorson f933519e2b unfinished header writing work 2011-12-23 06:09:23 -06:00
Peter Thorson d19ee815b8 unfinished send api work 2011-12-21 17:22:28 -06:00
Peter Thorson 4d03909d58 lots of misc fixes, mostly broadcast server related 2011-12-21 08:23:03 -06:00
Peter Thorson 3405a91e56 begins work on wscommand processing 2011-12-17 08:35:37 -06:00
Peter Thorson 5131f30d5a makefile fixes for ubuntu 2011-12-17 08:34:42 -06:00
Peter Thorson 9c1473ee91 stress client measures handshake speed 2011-12-15 07:02:43 -06:00
Peter Thorson 241985c2ee use nanosleep rather than sleep 2011-12-15 06:47:40 -06:00
Peter Thorson 217a81add8 more efficient broadcast_admin connection counting 2011-12-15 06:47:29 -06:00
Peter Thorson 57fb71d61d ignore unsolicited acks 2011-12-14 20:17:08 -06:00
Peter Thorson 10b28259f5 work on acknowledging broadcasted messages 2011-12-14 19:55:10 -06:00
Peter Thorson 3e9dc3f9df begins work to track broadcast message acks 2011-12-14 15:09:00 -06:00
Peter Thorson 9e14fba2f7 md5_hash_string now works with arbitrary length strings 2011-12-14 15:08:03 -06:00
Peter Thorson 190cf42231 disables expensive debug log statement 2011-12-14 11:18:08 -06:00
Peter Thorson b4afdb44e8 adjusts payload size reserve settings 2011-12-14 09:38:58 -06:00
Peter Thorson b67f1c41b6 misc config defaults and comments 2011-12-13 09:54:36 -06:00
Peter Thorson ebf0fa614c major work on the broadcast admin and stress client 2011-12-11 14:05:08 -06:00
Peter Thorson e7d3879df4 fixes stress client makefile 2011-12-10 11:34:58 -06:00
Peter Thorson a21d2a6be8 better error handling for FD limit detection 2011-12-10 07:29:28 -06:00
Peter Thorson 07cf4c9318 header fixes for warnings 2011-12-10 07:16:13 -06:00
Peter Thorson 47095fb73c stress client takes uri and connection amounts as arguments 2011-12-10 07:16:04 -06:00
Peter Thorson 649bd4ca36 broadcast server now has a javascript admin console 2011-12-10 07:15:43 -06:00
Peter Thorson e6f1ae286f more header rearranging for Ubuntu 2011-12-10 06:10:44 -06:00
Peter Thorson b219344245 header fixes 2011-12-09 20:03:18 -06:00
Peter Thorson 794dcf7b6c removes binaries 2011-12-09 20:00:24 -06:00
Peter Thorson 00a86b572e hack to link on ubuntu 2011-12-09 19:59:31 -06:00
Peter Thorson 730e46d5bf stress client updates to allow using more FDs 2011-12-09 19:28:20 -06:00
Peter Thorson dc55e67052 adds some code to broadcast server to allow it to increase its file descriptor limits on unix systems 2011-12-09 17:54:51 -06:00
Peter Thorson d89beda042 experimental fix for server running out of FDs 2011-12-09 17:54:17 -06:00
Peter Thorson 8c0ffeaf91 fixes for network errors discovered with new connection stress test example 2011-12-09 09:40:15 -06:00
Peter Thorson 0e9b0b99cf restructures fuzzing client to be more generic 2011-12-08 09:25:06 -06:00
Peter Thorson f92a5f5e8b adds set_handler to endpoint and connection 2011-12-08 09:24:47 -06:00
Peter Thorson 0660d4e87a temporary fix for static class constant in uri 2011-12-08 09:23:59 -06:00
Peter Thorson 008732f654 ignore binaries 2011-12-08 09:23:28 -06:00
Peter Thorson 25514a1476 some server fixes, addition of a fuzzing server and client example.
The fuzzing server and client are intended to mimic the Autobahn
versions and implement only the 9.* tests to enable performance testing
of implementations faster than AB
2011-12-07 09:17:38 -06:00
Peter Thorson 689c136298 policy refactor echo client passes all autobahn tests 2011-12-06 22:14:30 -06:00
Peter Thorson 0f5302d400 major work on echo client 2011-12-06 18:15:24 -06:00
Peter Thorson f1a724e0d4 more client work 2011-12-06 08:45:59 -06:00
Peter Thorson 695b8a4d30 adds get_port_str to URI 2011-12-06 08:44:34 -06:00
Peter Thorson efd5b8d8b1 preliminary cleanup for client role 2011-12-05 17:12:06 -06:00
Peter Thorson 14f0fe09f1 begins work on echo client 2011-12-05 14:41:34 -06:00
Peter Thorson f9a13dd5ff updates TLS example to use new read interface 2011-12-04 17:54:08 -06:00
Peter Thorson 51a03e401a tests disabling Nagle 2011-12-04 17:53:06 -06:00
Peter Thorson 7d11168c6b moves legacy files out to legacy folder, updates Xcode project 2011-12-04 09:13:26 -06:00
Peter Thorson b0978aa442 makefile and project updates 2011-12-04 08:44:18 -06:00
Peter Thorson ce9aa352e2 updates echo server example to use new read interface 2011-12-04 08:44:06 -06:00
Peter Thorson a637edd607 re-applies hybi_legacy support to server policy 2011-12-04 08:43:52 -06:00
Peter Thorson 8db1165331 updates connection to new processor read interface 2011-12-04 08:43:29 -06:00
Peter Thorson 42201b6161 updates hybi_legacy processor to new read interface 2011-12-04 08:43:14 -06:00
Peter Thorson b92d5853fb updates hybi processor to new read interface 2011-12-04 08:42:55 -06:00
Peter Thorson 302aaf2799 updates processor read interface 2011-12-04 08:42:25 -06:00
Peter Thorson 8b473530da connection socket policies now provide is_secure method 2011-12-04 08:41:35 -06:00
Peter Thorson 94d412ccc9 variable size and signedness fixes 2011-12-04 08:40:38 -06:00
Peter Thorson 6bbee85106 temporary fix until this file goes away entirely 2011-12-04 08:39:49 -06:00
Peter Thorson e67ec67b4b major restructuring 2011-12-04 08:39:19 -06:00
Peter Thorson 193ca13f93 fixes exceptions, refactors masking 2011-12-04 08:37:56 -06:00
Peter Thorson cc7170ddec fixes md5 bug 2011-12-04 08:28:39 -06:00
Peter Thorson 7b77f77171 changes the type of the URI port consts 2011-12-04 08:10:03 -06:00
Peter Thorson 280d6522be deletes more old files 2011-12-02 08:44:01 -06:00
Peter Thorson 88fb43d799 removes old files 2011-12-02 08:43:25 -06:00
Peter Thorson 991f37298a lots of work on the new read message queue 2011-12-02 08:43:07 -06:00
Peter Thorson b3f06b0cbd preliminary work on performance improvements to the message processing system 2011-12-01 17:55:05 -06:00
Peter Thorson c0887e0f3e updates Xcode project for new echo_server_tls target 2011-12-01 17:54:31 -06:00
Peter Thorson 82ddecd524 removes spurious xcode generated files 2011-12-01 17:54:06 -06:00
Peter Thorson 0c9f2768c7 fixes formatting 2011-12-01 17:52:58 -06:00
Peter Thorson e8fd5f69e4 adjusts some debugging code and fixes the TLS shutdown delay issue 2011-12-01 17:52:43 -06:00
Peter Thorson 9fd0d2f5bd ignore binaries 2011-12-01 17:50:46 -06:00
Peter Thorson fbc506292d splits echo_server example into separate plain and tls versions 2011-11-30 09:16:21 -06:00
Peter Thorson 309f62b273 bug fix - replaces include with forward declaration 2011-11-30 09:15:16 -06:00
Peter Thorson db37cb5278 handler typedef bugfix 2011-11-29 18:05:36 -06:00
Peter Thorson fabe61df86 adds handler and handler_ptr types to endpoint_traits as well as release documentation to entire file 2011-11-29 18:04:02 -06:00
Peter Thorson fb2fa0da94 adds handler data member to connections 2011-11-29 18:03:10 -06:00
Peter Thorson d2984b43da adjusts server handler interface to allow being a base class for endpoint handler 2011-11-29 18:02:41 -06:00
Peter Thorson ae854ca778 updates socket policies to expose handler interfaces, moves TLS context into connection 2011-11-29 18:01:39 -06:00
Peter Thorson 1cf694ec0a updates echo server for new TLS handler interface 2011-11-29 18:00:30 -06:00
Peter Thorson cb0222c06f updates library for new URI api 2011-11-29 09:38:32 -06:00
Peter Thorson 0e71fae008 updates makefiles and Xcode project 2011-11-29 09:38:03 -06:00
Peter Thorson 0b190adc90 Xcode project update 2011-11-29 06:55:30 -06:00
Peter Thorson dffc49cce8 playing around with logging APIs 2011-11-29 06:55:30 -06:00
Peter Thorson 0e0fd97b83 preliminary work to allow specifying custom paths to boost install 2011-11-28 08:40:04 -06:00
Peter Thorson 7d7e8e853a implements new URI processing interface and corrects associated unit tests 2011-11-28 08:39:11 -06:00
Peter Thorson 8e9d08489c corrects connection friend declaration bug 2011-11-28 08:37:09 -06:00
Peter Thorson e848e9bd2b messes with friends 2011-11-19 09:15:55 -06:00
Peter Thorson cb49e04474 many tweaks 2011-11-19 09:05:05 -06:00
Peter Thorson 7a0f9f3073 updates echo_server example 2011-11-19 01:18:28 -06:00
Peter Thorson 221693f975 merges all of the policy-refactor changes into one library. Policy refactor branch now passes all autobahn server tests except a few edge close behavior cases. 2011-11-19 00:52:38 -06:00
Peter Thorson 50efb8f996 moves public connection/session interface into the appropriate places 2011-11-18 08:46:05 -06:00
Peter Thorson 4fbcb13649 removes a bunch of debug code, adds friend setup, adds role specific connection policy, begins work to integrate http parser 2011-11-17 18:08:06 -06:00
Peter Thorson 3c86891ed7 refactors socket interface to use callbacks rather than CRTP 2011-11-17 08:56:19 -06:00
Peter Thorson 14f9f5d764 stupid git stuff 2011-11-16 09:13:59 -06:00
Peter Thorson 25504243d2 splitting out policy refactor into final files and namespaces 2011-11-16 09:06:28 -06:00
Peter Thorson dfb30b157a merge with new ssl and policy code 2011-11-15 20:09:58 -06:00
Peter Thorson d5ea5ed7d7 lots of policy testing 2011-11-15 17:51:44 -06:00
Peter Thorson 1ab2a8191f breaks a bunch of stuff 2011-11-14 09:21:21 -06:00
Peter Thorson 40a42dd637 misc fixes 2011-11-13 20:46:54 -06:00
Peter Thorson 4ed86a7c30 api tweaks, origin and uri detection behaviors. chat server updated for new apis 2011-11-13 07:12:37 -06:00
Peter Thorson 74aa325591 re-adds utf8 validation, passes all autobahn tests except edge close cases (reading invalid wire codes) starts working on chat server example update 2011-11-11 16:21:38 -06:00
Peter Thorson 0767a6ef18 fixes close behavior 2011-11-11 10:32:34 -06:00
Peter Thorson 6df22f5d70 first (partially) working copy of the refactored branch 2011-11-10 20:02:43 -06:00
Peter Thorson 3e7d71c9a1 refactoring 2011-11-10 09:09:36 -06:00
Peter Thorson 24b5ac278c more refactoring 2011-11-09 17:09:24 -06:00
Peter Thorson d2aaec6c78 refactoring to match new interfaces 2011-11-08 17:37:20 -06:00
Peter Thorson 02de3ebcdc sketches out some of the new interfaces 2011-11-08 08:27:00 -06:00
Peter Thorson 2bccdb21cb Adds hybi 00 handshake support, begins work on hybi 00 frame support 2011-11-07 17:28:28 -06:00
Peter Thorson 63eece760e refactors logging 2011-11-07 09:02:42 -06:00
Peter Thorson d6a59f459c http parser and logger work 2011-11-05 11:01:01 -05:00
Peter Thorson 7ff1e6a546 more refactoring! 2011-10-30 09:12:23 -05:00
Peter Thorson d806bea762 more work, compiles and passes tests now 2011-10-30 07:43:59 -05:00
Peter Thorson 95fe9d8966 more work 2011-10-29 12:39:23 -05:00
Peter Thorson 86da9f503c started policy-refactor branch 2011-10-28 17:09:36 -05:00
Peter Thorson b48733747e Merge branch 'master' of https://github.com/zaphoyd/websocketpp 2011-10-28 10:08:47 -05:00
Peter Thorson 67f83351d0 Xcode update 2011-10-28 10:08:44 -05:00
Peter Thorson a119700d67 Merge branch 'master' of github.com:zaphoyd/websocketpp 2011-10-28 09:36:37 -05:00
Peter Thorson 329c6b4d20 Xcode update 2011-10-28 09:36:34 -05:00
Peter Thorson 7ee3fe5653 Merge pull request #40 from zaphoyd/network-streaming
merges Network streaming branch into master
2011-10-28 07:28:52 -07:00
339 changed files with 45187 additions and 10267 deletions
+18
View File
@@ -0,0 +1,18 @@
# Lineendings
*.sln eol=crlf
*.vcproj eol=crlf
*.vcxproj* eol=crlf
# Whitespace rules
# strict (no trailing, no tabs)
*.cpp whitespace=trailing-space,space-before-tab,tab-in-indent,cr-at-eol
*.hpp whitespace=trailing-space,space-before-tab,tab-in-indent,cr-at-eol
*.c whitespace=trailing-space,space-before-tab,tab-in-indent,cr-at-eol
*.h whitespace=trailing-space,space-before-tab,tab-in-indent,cr-at-eol
# normal (no trailing)
*.sql whitespace=trailing-space,space-before-tab,cr-at-eol
*.txt whitespace=trailing-space,space-before-tab,cr-at-eol
# special files which must ignore whitespace
*.patch whitespace=-trailing-space
+70
View File
@@ -1,3 +1,7 @@
# make .git* files visible to git
!.gitignore
!.gitattributes
.DS_Store
#vim stuff
@@ -6,8 +10,36 @@
*.o
*.so
*.so.?
*.so.?.?.?
*.a
*.dylib
lib/*
# CMake
*.cmake
*.dir
CMakeFiles
INSTALL.*
ZERO_CHECK.*
CMakeCache.txt
install_manifest.txt
# Windows/Visual Studio
*.vcproj*
*.sln
*.suo
*.ncb
*/Debug/*
*/*/Debug/*
bin/Debug
*/Release/*
*/*/Release/*
*/RelWithDebInfo/*
*/*/RelWithDebInfo/*
# explicitly allow this path with /debug/ in it
!websocketpp/transport/debug/*
objs_shared/
objs_static/
@@ -22,3 +54,41 @@ libwebsocketpp.dylib.0.1.0
websocketpp.xcodeproj/xcuserdata/*
websocketpp.xcodeproj/project.xcworkspace/xcuserdata/*
policy_based_notes.hpp
examples/echo_server_tls/echo_server_tls
examples/fuzzing_client/fuzzing_client
examples/stress_client/stress_client
examples/broadcast_server_tls/broadcast_server
test/basic/perf
examples/echo_server_tls/echo_server_tls
examples/concurrent_server/concurrent_server
examples/fuzzing_server_tls/fuzzing_server
examples/wsperf/wsperf
.sconsign.dblite
build/
doxygen/
examples/wsperf/wsperf_client
*.out
*.log
*.opensdf
*.sdf
*.vcxproj
*.vcxproj.filters
*.user
install
Makefile
bin
Testing/Temporary/CTestCostData.txt
+21
View File
@@ -0,0 +1,21 @@
language: cpp
compiler:
- gcc
before_install:
#- sudo apt-get install libboost-chrono1.48-dev libboost-regex1.48-dev libboost-system1.48-dev libboost-thread1.48-dev libboost-test1.48-dev libboost-random1.48-dev -y
- sudo add-apt-repository -y ppa:boost-latest/ppa && sudo apt-get update -q && sudo apt-get install -y libboost-chrono1.55-dev libboost-random1.55-dev libboost-regex1.55-dev libboost-system1.55-dev libboost-thread1.55-dev libboost-test1.55-dev
env:
global:
- BOOST_INCLUDES=/usr/include
- BOOST_LIBS=/usr/lib/x86_64-linux-gnu
script: scons -j 2 && scons test
branches:
only:
- master
- develop
notifications:
recipients:
- travis@zaphoyd.com
email:
on_success: change
on_failure: always
+278
View File
@@ -0,0 +1,278 @@
############ Setup project and cmake
# Minimum cmake requirement. We should require a quite recent
# cmake for the dependency find macros etc. to be up to date.
cmake_minimum_required (VERSION 2.8.8)
############ Paths
set (WEBSOCKETPP_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set (WEBSOCKETPP_INCLUDE ${WEBSOCKETPP_ROOT}/websocketpp)
set (WEBSOCKETPP_BUILD_ROOT ${CMAKE_CURRENT_BINARY_DIR})
set (WEBSOCKETPP_BIN ${WEBSOCKETPP_BUILD_ROOT}/bin)
set (WEBSOCKETPP_LIB ${WEBSOCKETPP_BUILD_ROOT}/lib)
# CMake install step prefix. I assume linux users want the prefix to
# be the default /usr or /usr/local so this is only adjusted on Windows.
# This must be set prior to any call to project or it will not be read correctly.
# - Windows: Build the INSTALL project in your solution file.
# - Linux/OSX: make install.
if (WIN32)
set (CMAKE_INSTALL_PREFIX "${WEBSOCKETPP_ROOT}/install" CACHE PATH "")
endif ()
############ Project name and version
set (WEBSOCKETPP_MAJOR_VERSION 0)
set (WEBSOCKETPP_MINOR_VERSION 8)
set (WEBSOCKETPP_PATCH_VERSION 0)
set (WEBSOCKETPP_VERSION ${WEBSOCKETPP_MAJOR_VERSION}.${WEBSOCKETPP_MINOR_VERSION}.${WEBSOCKETPP_PATCH_VERSION})
if(POLICY CMP0048)
cmake_policy(GET CMP0048 _version_policy)
endif()
if(_version_allowed STREQUAL NEW)
project (websocketpp VERSION ${WEBSOCKETPP_VERSION})
else()
project (websocketpp)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
if (WIN32 AND NOT CYGWIN)
set (DEF_INSTALL_CMAKE_DIR cmake)
else ()
set (DEF_INSTALL_CMAKE_DIR lib/cmake/websocketpp)
endif ()
set (INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
# Make relative paths absolute (needed later on)
foreach (p INCLUDE CMAKE)
set (var INSTALL_${p}_DIR)
if (NOT IS_ABSOLUTE "${${var}}")
set (${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif ()
endforeach ()
# Set CMake library search policy
if (COMMAND cmake_policy)
cmake_policy (SET CMP0003 NEW)
cmake_policy (SET CMP0005 NEW)
endif ()
# Disable unnecessary build types
set (CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug" CACHE STRING "Configurations" FORCE)
# Include our cmake macros
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include (CMakeHelpers)
############ Build customization
# Override from command line "CMake -D<OPTION>=TRUE/FALSE/0/1/ON/OFF"
option (ENABLE_CPP11 "Build websocketpp with CPP11 features enabled." TRUE)
option (BUILD_EXAMPLES "Build websocketpp examples." FALSE)
option (BUILD_TESTS "Build websocketpp tests." FALSE)
if (BUILD_TESTS OR BUILD_EXAMPLES)
enable_testing ()
############ Compiler specific setup
set (WEBSOCKETPP_PLATFORM_LIBS "")
set (WEBSOCKETPP_PLATFORM_TLS_LIBS "")
set (WEBSOCKETPP_BOOST_LIBS "")
# VC9 and C++11 reasoning
if (ENABLE_CPP11 AND MSVC AND MSVC90)
message("* Detected Visual Studio 9 2008, disabling C++11 support.")
set (ENABLE_CPP11 FALSE)
endif ()
# Detect clang. Not officially reported by cmake.
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-v" ERROR_VARIABLE CXX_VER_STDERR)
if ("${CXX_VER_STDERR}" MATCHES ".*clang.*")
set (CMAKE_COMPILER_IS_CLANGXX 1)
endif ()
# C++11 defines
if (ENABLE_CPP11)
if (MSVC)
add_definitions (-D_WEBSOCKETPP_CPP11_FUNCTIONAL_)
add_definitions (-D_WEBSOCKETPP_CPP11_SYSTEM_ERROR_)
add_definitions (-D_WEBSOCKETPP_CPP11_RANDOM_DEVICE_)
add_definitions (-D_WEBSOCKETPP_CPP11_MEMORY_)
else()
add_definitions (-D_WEBSOCKETPP_CPP11_STL_)
endif()
endif ()
# Visual studio
if (MSVC)
set (WEBSOCKETPP_BOOST_LIBS system thread)
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL /Gy /GF /Ox /Ob2 /Ot /Oi /MP /arch:SSE2 /fp:fast")
set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF")
add_definitions (/W3 /wd4996 /wd4995 /wd4355)
add_definitions (-DUNICODE -D_UNICODE)
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
add_definitions (-DNOMINMAX)
endif ()
# g++
if (CMAKE_COMPILER_IS_GNUCXX)
set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
set (WEBSOCKETPP_PLATFORM_TLS_LIBS ssl crypto)
set (WEBSOCKETPP_BOOST_LIBS system thread)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
if (NOT APPLE)
add_definitions (-DNDEBUG -Wall -Wcast-align) # todo: should we use CMAKE_C_FLAGS for these?
endif ()
# Try to detect version. Note: Not tested!
execute_process (COMMAND ${CMAKE_CXX_COMPILER} "-dumpversion" OUTPUT_VARIABLE GCC_VERSION)
if ("${GCC_VERSION}" STRGREATER "4.4.0")
message("* C++11 support partially enabled due to GCC version ${GCC_VERSION}")
set (WEBSOCKETPP_BOOST_LIBS system thread)
endif ()
endif ()
# clang
if (CMAKE_COMPILER_IS_CLANGXX)
if (NOT APPLE)
set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
else()
set (WEBSOCKETPP_PLATFORM_LIBS pthread)
endif()
set (WEBSOCKETPP_PLATFORM_TLS_LIBS ssl crypto)
set (WEBSOCKETPP_BOOST_LIBS system thread)
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++0x -stdlib=libc++") # todo: is libc++ really needed here?
if (NOT APPLE)
add_definitions (-DNDEBUG -Wall -Wno-padded) # todo: should we use CMAKE_C_FLAGS for these?
endif ()
endif ()
# OSX, can override above.
if (APPLE)
add_definitions (-DNDEBUG -Wall)
endif ()
if (BUILD_EXAMPLES)
list (APPEND WEBSOCKETPP_BOOST_LIBS random)
endif()
if (BUILD_TESTS)
list (APPEND WEBSOCKETPP_BOOST_LIBS unit_test_framework)
endif()
############ Dependencies
# Set BOOST_ROOT env variable or pass with cmake -DBOOST_ROOT=path.
# BOOST_ROOT can also be defined by a previous run from cmake cache.
if (NOT "$ENV{BOOST_ROOT_CPP11}" STREQUAL "")
# Scons documentation for BOOST_ROOT_CPP11:
# "look for optional second boostroot compiled with clang's libc++ STL library
# this prevents warnings/errors when linking code built with two different
# incompatible STL libraries."
file (TO_CMAKE_PATH "$ENV{BOOST_ROOT_CPP11}" BOOST_ROOT)
set (BOOST_ROOT ${BOOST_ROOT} CACHE PATH "BOOST_ROOT dependency path" FORCE)
endif ()
if ("${BOOST_ROOT}" STREQUAL "")
file (TO_CMAKE_PATH "$ENV{BOOST_ROOT}" BOOST_ROOT)
# Cache BOOST_ROOT for runs that do not define $ENV{BOOST_ROOT}.
set (BOOST_ROOT ${BOOST_ROOT} CACHE PATH "BOOST_ROOT dependency path" FORCE)
endif ()
message ("* Configuring Boost")
message (STATUS "-- Using BOOST_ROOT")
message (STATUS " " ${BOOST_ROOT})
if (MSVC)
set (Boost_USE_MULTITHREADED TRUE)
set (Boost_USE_STATIC_LIBS TRUE)
else ()
set (Boost_USE_MULTITHREADED FALSE)
set (Boost_USE_STATIC_LIBS FALSE)
endif ()
if (BOOST_STATIC)
set (Boost_USE_STATIC_LIBS TRUE)
endif ()
if (NOT Boost_USE_STATIC_LIBS)
add_definitions (/DBOOST_TEST_DYN_LINK)
endif ()
set (Boost_FIND_REQUIRED TRUE)
set (Boost_FIND_QUIETLY TRUE)
set (Boost_DEBUG FALSE)
set (Boost_USE_MULTITHREADED TRUE)
set (Boost_ADDITIONAL_VERSIONS "1.39.0" "1.40.0" "1.41.0" "1.42.0" "1.43.0" "1.44.0" "1.46.1") # todo: someone who knows better spesify these!
find_package (Boost 1.39.0 COMPONENTS "${WEBSOCKETPP_BOOST_LIBS}")
if (Boost_FOUND)
# Boost is a project wide global dependency.
include_directories (${Boost_INCLUDE_DIRS})
link_directories (${Boost_LIBRARY_DIRS})
# Pretty print status
message (STATUS "-- Include Directories")
foreach (include_dir ${Boost_INCLUDE_DIRS})
message (STATUS " " ${include_dir})
endforeach ()
message (STATUS "-- Library Directories")
foreach (library_dir ${Boost_LIBRARY_DIRS})
message (STATUS " " ${library_dir})
endforeach ()
message (STATUS "-- Libraries")
foreach (boost_lib ${Boost_LIBRARIES})
message (STATUS " " ${boost_lib})
endforeach ()
message ("")
else ()
message (FATAL_ERROR "Failed to find required dependency: boost")
endif ()
find_package(OpenSSL)
find_package(ZLIB)
endif()
############ Add projects
# Add main library
add_subdirectory (websocketpp)
# Add examples
if (BUILD_EXAMPLES)
include_subdirs ("examples")
endif ()
# Add tests
if (BUILD_TESTS)
include_subdirs ("test")
endif ()
print_used_build_config()
export (PACKAGE websocketpp)
include(CMakePackageConfigHelpers)
configure_package_config_file(websocketpp-config.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-config.cmake"
PATH_VARS INSTALL_INCLUDE_DIR
INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}"
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file("${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-configVersion.cmake"
VERSION ${WEBSOCKETPP_VERSION}
COMPATIBILITY ExactVersion)
# Install the websocketpp-config.cmake and websocketpp-configVersion.cmake
install (FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-config.cmake"
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-configVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
+145
View File
@@ -0,0 +1,145 @@
Main Library:
Copyright (c) 2014, Peter Thorson. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the WebSocket++ Project nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Bundled Libraries:
****** Base 64 Library (base64/base64.hpp) ******
base64.hpp is a repackaging of the base64.cpp and base64.h files into a
single header suitable for use as a header only library. This conversion was
done by Peter Thorson (webmaster@zaphoyd.com) in 2012. All modifications to
the code are redistributed under the same license as the original, which is
listed below.
base64.cpp and base64.h
Copyright (C) 2004-2008 René Nyffenegger
This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
****** SHA1 Library (sha1/sha1.hpp) ******
sha1.hpp is a repackaging of the sha1.cpp and sha1.h files from the shallsha1
library (http://code.google.com/p/smallsha1/) into a single header suitable for
use as a header only library. This conversion was done by Peter Thorson
(webmaster@zaphoyd.com) in 2013. All modifications to the code are redistributed
under the same license as the original, which is listed below.
Copyright (c) 2011, Micael Hildenborg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Micael Hildenborg nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Micael Hildenborg ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Micael Hildenborg BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
****** MD5 Library (common/md5.hpp) ******
md5.hpp is a reformulation of the md5.h and md5.c code from
http://www.opensource.apple.com/source/cups/cups-59/cups/md5.c to allow it to
function as a component of a header only library. This conversion was done by
Peter Thorson (webmaster@zaphoyd.com) in 2012 for the WebSocket++ project. The
changes are released under the same license as the original (listed below)
Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
L. Peter Deutsch
ghost@aladdin.com
****** UTF8 Validation logic (utf8_validation.hpp) ******
utf8_validation.hpp is adapted from code originally written by Bjoern Hoehrmann
<bjoern@hoehrmann.de>. See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for
details.
The original license:
Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+2355
View File
File diff suppressed because it is too large Load Diff
-201
View File
@@ -1,201 +0,0 @@
################################################################################
#
# Copyright (c) 2011, Peter Thorson. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the WebSocket++ Project nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# This Makefile was derived from a similar one included in the libjson project
# It's authors were Jonathan Wallace and Bernhard Fluehmann.
objects = websocket_server_session.o websocket_client_session.o websocket_session.o websocket_server.o websocket_client.o websocket_frame.o \
network_utilities.o sha1.o base64.o
libs = -lboost_system -lboost_date_time -lboost_regex -lboost_random
OS=$(shell uname)
# Defaults
ifeq ($(OS), Darwin)
cxxflags_default = -c -O2 -DNDEBUG
else
cxxflags_default = -c -O2 -DNDEBUG
endif
cxxflags_small = -c
cxxflags_debug = -c -g
cxxflags_shared = -f$(PIC)
libname = libwebsocketpp
libname_hdr = websocketpp
libname_debug = $(libname)
suffix_shared = so
suffix_shared_darwin = dylib
suffix_static = a
major_version = 0
minor_version = 1.0
objdir = objs
# Variables
prefix ?= /usr/local
exec_prefix ?= $(prefix)
libdir ?= lib
includedir ?= include
srcdir ?= src
CXX ?= c++
AR ?= ar
PIC ?= PIC
BUILD_TYPE ?= "default"
SHARED ?= "1"
# Internal Variables
inst_path = $(exec_prefix)/$(libdir)
include_path = $(prefix)/$(includedir)
# BUILD_TYPE specific settings
ifeq ($(BUILD_TYPE), debug)
CXXFLAGS = $(cxxflags_debug)
libname := $(libname_debug)
else
CXXFLAGS ?= $(cxxflags_default)
endif
# SHARED specific settings
ifeq ($(SHARED), 1)
ifeq ($(OS), Darwin)
libname_shared = $(libname).$(suffix_shared_darwin)
else
libname_shared = $(libname).$(suffix_shared)
endif
libname_shared_major_version = $(libname_shared).$(major_version)
lib_target = $(libname_shared_major_version).$(minor_version)
objdir := $(objdir)_shared
CXXFLAGS := $(CXXFLAGS) $(cxxflags_shared)
else
lib_target = $(libname).$(suffix_static)
objdir := $(objdir)_static
endif
# Phony targets
.PHONY: all banner installdirs install install_headers clean uninstall \
uninstall_headers
# Targets
all: $(lib_target)
@echo "============================================================"
@echo "Done"
@echo "============================================================"
banner:
@echo "============================================================"
@echo "libwebsocketpp version: "$(major_version).$(minor_version) "target: "$(target) "OS: "$(OS)
@echo "============================================================"
installdirs: banner
mkdir -p $(objdir)
# Libraries
ifeq ($(SHARED),1)
$(lib_target): banner installdirs $(addprefix $(objdir)/, $(objects))
@echo "Link "
cd $(objdir) ; \
if test "$(OS)" = "Darwin" ; then \
$(CXX) -dynamiclib $(libs) -Wl,-dylib_install_name -Wl,$(libname_shared_major_version) -o $@ $(objects) ; \
else \
$(CXX) -shared $(libs) -Wl,-soname,$(libname_shared_major_version) -o $@ $(objects) ; \
fi ; \
mv -f $@ ../
@echo "Link: Done"
else
$(lib_target): banner installdirs $(addprefix $(objdir)/, $(objects))
@echo "Archive"
cd $(objdir) ; \
$(AR) -cvq $@ $(objects) ; \
mv -f $@ ../
@echo "Archive: Done"
endif
# Compile object files
$(objdir)/sha1.o: $(srcdir)/sha1/sha1.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
$(objdir)/base64.o: $(srcdir)/base64/base64.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
$(objdir)/%.o: $(srcdir)/%.cpp
$(CXX) $< -o $@ $(CXXFLAGS)
ifeq ($(SHARED),1)
install: banner install_headers $(lib_target)
@echo "Install shared library"
cp -f ./$(lib_target) $(inst_path)
cd $(inst_path) ; \
ln -sf $(lib_target) $(libname_shared_major_version) ; \
ln -sf $(libname_shared_major_version) $(libname_shared)
ifneq ($(OS),Darwin)
ldconfig
endif
@echo "Install shared library: Done."
else
install: banner install_headers $(lib_target)
@echo "Install static library"
cp -f ./$(lib_target) $(inst_path)
@echo "Install static library: Done."
endif
install_headers: banner
@echo "Install header files"
mkdir -p $(include_path)/$(libname_hdr)
# cp -f ./*.hpp $(include_path)/$(libname_hdr)
cp -f ./$(srcdir)/*.hpp $(include_path)/$(libname_hdr)
mkdir -p $(include_path)/$(libname_hdr)/base64
cp -f ./$(srcdir)/base64/base64.h $(include_path)/$(libname_hdr)/base64
mkdir -p $(include_path)/$(libname_hdr)/sha1
cp -f ./$(srcdir)/sha1/sha1.h $(include_path)/$(libname_hdr)/sha1
chmod -R a+r $(include_path)/$(libname_hdr)
find $(include_path)/$(libname_hdr) -type d -exec chmod a+x {} \;
@echo "Install header files: Done."
clean: banner
@echo "Clean library and object folder"
rm -rf $(objdir)
rm -f $(lib_target)
@echo "Clean library and object folder: Done"
ifeq ($(SHARED),1)
uninstall: banner uninstall_headers
@echo "Uninstall shared library"
rm -f $(inst_path)/$(libname_shared)
rm -f $(inst_path)/$(libname_shared_major_version)
rm -f $(inst_path)/$(lib_target)
ldconfig
@echo "Uninstall shared library: Done"
else
uninstall: banner uninstall_headers
@echo "Uninstall static library"
rm -f $(inst_path)/$(lib_target)
@echo "Uninstall static library: Done"
endif
uninstall_headers: banner
@echo "Uninstall header files"
rm -rf $(include_path)/$(libname)
@echo "Uninstall header files: Done"
+285
View File
@@ -0,0 +1,285 @@
import os, sys, commands
env = Environment(ENV = os.environ)
# figure out a better way to configure this
if os.environ.has_key('CXX'):
env['CXX'] = os.environ['CXX']
if os.environ.has_key('DEBUG'):
env['DEBUG'] = os.environ['DEBUG']
if os.environ.has_key('CXXFLAGS'):
#env['CXXFLAGS'] = os.environ['CXXFLAGS']
env.Append(CXXFLAGS = os.environ['CXXFLAGS'])
if os.environ.has_key('LINKFLAGS'):
#env['LDFLAGS'] = os.environ['LDFLAGS']
env.Append(LINKFLAGS = os.environ['LINKFLAGS'])
## Boost
##
## Note: You need to either set BOOSTROOT to the root of a stock Boost distribution
## or set BOOST_INCLUDES and BOOST_LIBS if Boost comes with your OS distro e.g. and
## needs BOOST_INCLUDES=/usr/include/boost and BOOST_LIBS=/usr/lib like Ubuntu.
##
if os.environ.has_key('BOOSTROOT'):
os.environ['BOOST_ROOT'] = os.environ['BOOSTROOT']
if os.environ.has_key('BOOST_ROOT'):
env['BOOST_INCLUDES'] = os.environ['BOOST_ROOT']
env['BOOST_LIBS'] = os.path.join(os.environ['BOOST_ROOT'], 'stage', 'lib')
elif os.environ.has_key('BOOST_INCLUDES') and os.environ.has_key('BOOST_LIBS'):
env['BOOST_INCLUDES'] = os.environ['BOOST_INCLUDES']
env['BOOST_LIBS'] = os.environ['BOOST_LIBS']
else:
raise SCons.Errors.UserError, "Neither BOOST_ROOT, nor BOOST_INCLUDES + BOOST_LIBS was set!"
## Custom OpenSSL
if os.environ.has_key('OPENSSL_PATH'):
env.Append(CPPPATH = os.path.join(os.environ['OPENSSL_PATH'], 'include'))
env.Append(LIBPATH = os.environ['OPENSSL_PATH'])
if os.environ.has_key('WSPP_ENABLE_CPP11'):
env['WSPP_ENABLE_CPP11'] = True
else:
env['WSPP_ENABLE_CPP11'] = False
boost_linkshared = False
def boostlibs(libnames,localenv):
if localenv['PLATFORM'].startswith('win'):
# Win/VC++ supports autolinking. nothing to do.
# http://www.boost.org/doc/libs/1_49_0/more/getting_started/windows.html#auto-linking
return []
else:
libs = []
prefix = localenv['SHLIBPREFIX'] if boost_linkshared else localenv['LIBPREFIX']
suffix = localenv['SHLIBSUFFIX'] if boost_linkshared else localenv['LIBSUFFIX']
for name in libnames:
lib = File(os.path.join(localenv['BOOST_LIBS'], '%sboost_%s%s' % (prefix, name, suffix)))
libs.append(lib)
return libs
if env['PLATFORM'].startswith('win'):
env.Append(CPPDEFINES = ['WIN32',
'NDEBUG',
'WIN32_LEAN_AND_MEAN',
'_WIN32_WINNT=0x0600',
'_CONSOLE',
'BOOST_TEST_DYN_LINK',
'NOMINMAX',
'_WEBSOCKETPP_CPP11_MEMORY_',
'_WEBSOCKETPP_CPP11_FUNCTIONAL_'])
arch_flags = '/arch:SSE2'
opt_flags = '/Ox /Oi /fp:fast'
warn_flags = '/W3 /wd4996 /wd4995 /wd4355'
env['CCFLAGS'] = '%s /EHsc /GR /GS- /MD /nologo %s %s' % (warn_flags, arch_flags, opt_flags)
env['LINKFLAGS'] = '/INCREMENTAL:NO /MANIFEST /NOLOGO /OPT:REF /OPT:ICF /MACHINE:X86'
elif env['PLATFORM'] == 'posix':
if env.has_key('DEBUG'):
env.Append(CCFLAGS = ['-g', '-O0'])
else:
env.Append(CPPDEFINES = ['NDEBUG'])
env.Append(CCFLAGS = ['-O1', '-fomit-frame-pointer'])
env.Append(CCFLAGS = ['-Wall'])
#env['LINKFLAGS'] = ''
elif env['PLATFORM'] == 'darwin':
if not os.environ.has_key('CXX'):
env['CXX'] = "clang++"
if env.has_key('DEBUG'):
env.Append(CCFLAGS = ['-g', '-O0'])
else:
env.Append(CPPDEFINES = ['NDEBUG'])
env.Append(CCFLAGS = ['-O1', '-fomit-frame-pointer'])
env.Append(CCFLAGS = ['-Wall'])
#env['LINKFLAGS'] = ''
if env['PLATFORM'].startswith('win'):
#env['LIBPATH'] = env['BOOST_LIBS']
pass
else:
env.Append(LIBPATH = ['/usr/lib', '/usr/local/lib'])
# Compiler specific warning flags
if env['CXX'].startswith('g++'):
#env.Append(CCFLAGS = ['-Wconversion'])
env.Append(CCFLAGS = ['-Wcast-align'])
env.Append(CCFLAGS = ['-Wshadow'])
env.Append(CCFLAGS = ['-Wunused-parameter'])
elif env['CXX'].startswith('clang++'):
#env.Append(CCFLAGS = ['-Wcast-align'])
#env.Append(CCFLAGS = ['-Wglobal-constructors'])
#env.Append(CCFLAGS = ['-Wconversion'])
env.Append(CCFLAGS = ['-Wno-padded'])
env.Append(CCFLAGS = ['-Wshadow'])
env.Append(CCFLAGS = ['-Wunused-parameter'])
env.Append(CCFLAGS = ['-Wsometimes-uninitialized'])
env.Append(CCFLAGS = ['-Wuninitialized'])
#env.Append(CCFLAGS = ['-Weverything'])
#env.Append(CCFLAGS = ['-Wno-documentation'])
#env.Append(CCFLAGS = ['-Wno-weak-vtables'])
#env.Append(CCFLAGS = ['-Wno-global-constructors'])
#env.Append(CCFLAGS = ['-Wno-sign-conversion'])
#env.Append(CCFLAGS = ['-Wno-exit-time-destructors'])
# Wpadded
# Wsign-conversion
#
platform_libs = []
tls_libs = []
tls_build = False
if env['PLATFORM'] == 'posix':
platform_libs = ['pthread', 'rt']
tls_libs = ['ssl', 'crypto']
tls_build = True
elif env['PLATFORM'] == 'darwin':
tls_libs = ['ssl', 'crypto']
tls_build = True
elif env['PLATFORM'].startswith('win'):
# Win/VC++ supports autolinking. nothing to do.
pass
## Append WebSocket++ path
env.Append(CPPPATH = ['#'])
##### Set up C++11 environment
polyfill_libs = [] # boost libraries used as drop in replacements for incomplete
# C++11 STL implementations
env_cpp11 = env.Clone ()
if env_cpp11['CXX'].startswith('g++'):
# TODO: check g++ version
GCC_VERSION = commands.getoutput(env_cpp11['CXX'] + ' -dumpversion')
if GCC_VERSION > "4.4.0":
print "C++11 build environment partially enabled"
env_cpp11.Append(WSPP_CPP11_ENABLED = "true",CXXFLAGS = ['-std=c++0x'],TOOLSET = ['g++'],CPPDEFINES = ['_WEBSOCKETPP_CPP11_STL_'])
else:
print "C++11 build environment is not supported on this version of G++"
elif env_cpp11['CXX'].startswith('clang++'):
print "C++11 build environment enabled"
env.Append(CXXFLANGS = ['-stdlib=libc++'],LINKFLAGS=['-stdlib=libc++'])
env_cpp11.Append(WSPP_CPP11_ENABLED = "true",CXXFLAGS = ['-std=c++0x','-stdlib=libc++'],LINKFLAGS = ['-stdlib=libc++'],TOOLSET = ['clang++'],CPPDEFINES = ['_WEBSOCKETPP_CPP11_STL_'])
# look for optional second boostroot compiled with clang's libc++ STL library
# this prevents warnings/errors when linking code built with two different
# incompatible STL libraries.
if os.environ.has_key('BOOST_ROOT_CPP11'):
env_cpp11['BOOST_INCLUDES'] = os.environ['BOOST_ROOT_CPP11']
env_cpp11['BOOST_LIBS'] = os.path.join(os.environ['BOOST_ROOT_CPP11'], 'stage', 'lib')
elif os.environ.has_key('BOOST_INCLUDES_CPP11') and os.environ.has_key('BOOST_LIBS_CPP11'):
env_cpp11['BOOST_INCLUDES'] = os.environ['BOOST_INCLUDES_CPP11']
env_cpp11['BOOST_LIBS'] = os.environ['BOOST_LIBS_CPP11']
else:
print "C++11 build environment disabled"
# if the build system is known to allow the isystem modifier for library include
# values then use it for the boost libraries. Otherwise just add them to the
# regular CPPPATH values.
if env['CXX'].startswith('g++') or env['CXX'].startswith('clang'):
env.Append(CPPFLAGS = '-isystem ' + env['BOOST_INCLUDES'])
else:
env.Append(CPPPATH = [env['BOOST_INCLUDES']])
env.Append(LIBPATH = [env['BOOST_LIBS']])
# if the build system is known to allow the isystem modifier for library include
# values then use it for the boost libraries. Otherwise just add them to the
# regular CPPPATH values.
if env_cpp11['CXX'].startswith('g++') or env_cpp11['CXX'].startswith('clang'):
env_cpp11.Append(CPPFLAGS = '-isystem ' + env_cpp11['BOOST_INCLUDES'])
else:
env_cpp11.Append(CPPPATH = [env_cpp11['BOOST_INCLUDES']])
env_cpp11.Append(LIBPATH = [env_cpp11['BOOST_LIBS']])
releasedir = 'build/release/'
debugdir = 'build/debug/'
testdir = 'build/test/'
builddir = releasedir
Export('env')
Export('env_cpp11')
Export('platform_libs')
Export('boostlibs')
Export('tls_libs')
Export('polyfill_libs')
## END OF CONFIG !!
## TARGETS:
if not env['PLATFORM'].startswith('win'):
# Unit tests, add test folders with SConscript files to to_test list.
to_test = ['utility','http','logger','random','processors','message_buffer','extension','transport/iostream','transport/asio','roles','endpoint','connection','transport'] #,'http','processors','connection'
for t in to_test:
new_tests = SConscript('#/test/'+t+'/SConscript',variant_dir = testdir + t, duplicate = 0)
for a in new_tests:
new_alias = Alias('test', [a], a.abspath)
AlwaysBuild(new_alias)
# Main test application
#main = SConscript('#/examples/dev/SConscript',variant_dir = builddir + 'dev',duplicate = 0)
# echo_server
echo_server = SConscript('#/examples/echo_server/SConscript',variant_dir = builddir + 'echo_server',duplicate = 0)
# echo_client
echo_client = SConscript('#/examples/echo_client/SConscript',variant_dir = builddir + 'echo_client',duplicate = 0)
# print_client
print_client = SConscript('#/examples/print_client/SConscript',variant_dir = builddir + 'print_client',duplicate = 0)
# echo_server_tls
if tls_build:
echo_server_tls = SConscript('#/examples/echo_server_tls/SConscript',variant_dir = builddir + 'echo_server_tls',duplicate = 0)
echo_server_both = SConscript('#/examples/echo_server_both/SConscript',variant_dir = builddir + 'echo_server_both',duplicate = 0)
print_client_tls = SConscript('#/examples/print_client_tls/SConscript',variant_dir = builddir + 'print_client_tls',duplicate = 0)
# broadcast_server
broadcast_server = SConscript('#/examples/broadcast_server/SConscript',variant_dir = builddir + 'broadcast_server',duplicate = 0)
# testee_server
testee_server = SConscript('#/examples/testee_server/SConscript',variant_dir = builddir + 'testee_server',duplicate = 0)
# testee_client
testee_client = SConscript('#/examples/testee_client/SConscript',variant_dir = builddir + 'testee_client',duplicate = 0)
# scratch_client
scratch_client = SConscript('#/examples/scratch_client/SConscript',variant_dir = builddir + 'scratch_client',duplicate = 0)
# scratch_server
scratch_server = SConscript('#/examples/scratch_server/SConscript',variant_dir = builddir + 'scratch_server',duplicate = 0)
# debug_client
debug_client = SConscript('#/examples/debug_client/SConscript',variant_dir = builddir + 'debug_client',duplicate = 0)
# debug_server
debug_server = SConscript('#/examples/debug_server/SConscript',variant_dir = builddir + 'debug_server',duplicate = 0)
# subprotocol_server
subprotocol_server = SConscript('#/examples/subprotocol_server/SConscript',variant_dir = builddir + 'subprotocol_server',duplicate = 0)
# telemetry_server
telemetry_server = SConscript('#/examples/telemetry_server/SConscript',variant_dir = builddir + 'telemetry_server',duplicate = 0)
# external_io_service
external_io_service = SConscript('#/examples/external_io_service/SConscript',variant_dir = builddir + 'external_io_service',duplicate = 0)
if not env['PLATFORM'].startswith('win'):
# iostream_server
iostream_server = SConscript('#/examples/iostream_server/SConscript',variant_dir = builddir + 'iostream_server',duplicate = 0)
# telemetry_client
telemetry_client = SConscript('#/examples/telemetry_client/SConscript',variant_dir = builddir + 'telemetry_client',duplicate = 0)
# print_server
print_server = SConscript('#/examples/print_server/SConscript',variant_dir = builddir + 'print_server',duplicate = 0)
+424
View File
@@ -0,0 +1,424 @@
HEAD
0.8.0 - 2018-07-12
- Examples: Add `print_client` example. This demonstrates a minimal non-TLS
client that connects to a server and prints out the messages it receives.
- Examples: Add `print_client_tls` example. This demonstrates a minimal TLS
client, including basic support via Asio+OpenSSL for certificate chain
and hostname verification.
- Feature: Add getter for all headers to the HTTP parsers. This allows a
wrapping library to enumerate all headers to send upstream. Thank you Jupp
Müller for reporting and an initial pull request.
- Improvement: Move the `socket_init_handler` to execute as a part of `init_asio`
rather than connection `pre_init`. This allows setting of socket options prior
to the bind/listen/accept system calls. Thank you ChristianRobl3D for
reporting #530.
- Improvement: Timers in transport integration tests should only fail if their
own test times out, rather than any test. #643 Thank you Alex Korotkin for
reporting and a patch.
- Improvement: Preserve transport layer error codes in more cases, particularly
during calls to `endpoint::listen`. #652 Thank you vadz for reporting and
patches.
- Compatibility: Make sure the chrono library used by Boost/Asio is in sync
with what the websocketpp is using. Thank you Flow86 for reporting and a
patch.
- Compatibility: Update `telemetry_client` to use a slightly more cross platform
method of sleeping. Should work on windows now. Thank you Meir Yanovich for
reporting.
- Compatibility: Updated permessage-deflate support to reflect that the zlib
library does not actually support a sliding window size of 256 bits.
WebSocket++ will no longer negotiate 256 bit deflate windows. If the user
of the library tries to request a 256 bit window a 512 bit window will be
specified instead (This was the previous behavior). #596 #653 Thank you
Vinnie Falco and Gianfranco Costamagna for reporting.
- Compatibility: Better error handling and logging in cases where extension
requests parse correctly but negotiation fails.
- Compatibility: Removed custom handling of `SSL_R_SHORT_READ` error condition.
This error code no longer exists in modern versions of OpenSSL and causes
a build error. It wasn't being used for anything particularly important
(slightly improving error reporting) and there isn't a great replacement.
#599 Thank you Gianfranco Costamagna for reporting.
- Compatibility: Add missing `<stdint>` headers. Fixes issues with g++ 5.4.0.
#638 Thank you Alex Korotkin for reporting and a patch.
- Compatibility: Remove the use of `std::auto_ptr` and `std::binary_function`
from builds with C++11 or later. These features are deprecated and were
removed entirely in C++17. This change allows building WebSocket++ on
C++17 compilers. #592 Thank you Michal Fojtak for reporting and a patch
- Compatibility: Add 1014 close code and adds missing descriptions for codes
1012 and 1013. #589 Thank you jbwdevries and ronneke1996 for reporting and
patches.
- Compatibility: Add hooks to support `mingw-std-threads` C++11 thread and mutex
polyfill library as an alternative to Boost. #608 Thank you Peter Taylor for
reporting and an initial patch.
- Compatibility: Changed the handshake connection token to 'Upgrade' from
'upgrade'. Technically this header is supposed to be processed case
insensitively. In practice, there are browsers (such as Edge) that don't do
this and they tend to use the uppercase value used as an example in RFC6455.
Thank you Johann Bauer for reporting and a patch. #727
- Bug: Store loggers in shared pointers to avoid crashes related to connections
trying to write logs entries after their respective endpoint has been
deallocated. Thank you Thalhammer for reporting and Jupp Müller for the
patch. #539 #501
- Bug: Change default listen backlog from 0 to `socket_base::max_connections`.
#549. Thank you derwassi and zwelab for reporting and na1pir for providing
access to hardware to debug the issue.
- Bug: Fix a crash in the accept loop when `get_connection` fails. #551 Thank you
Walter Gray for a patch.
- Bug/Documentation: Fix incorrect example code that used
`websocketpp::lib::error_code` instead of `websocketpp::exception`. Thank you
heretic13 for reporting
- Bug: Fix uninitialized shared pointer in Asio transport test suite. #647
Thank you Alex Korotkin for reporting and a patch.
- Bug: Fix a thread safety issue in the permessage-deflate extension that
caused message corruption when sending compressed messages from a different
thread than the main I/O thread. #615 Thank you KyleNyenhuis and Pieter De
Gendt for reporting and a patch.
- Bug: Fix an undefined behavior issue performing a 64 bit wide shift on a 64
bit value. #636 Thank you Gregor Jasny for reporting and a patch
- Bug: Fix some compile issues with ASIO_STANDALONE. #662 #665 Thank you
chronoxor and Guillaume Egles for reporting and patches.
0.7.0 - 2016-02-22
- MINOR BREAKING SOCKET POLICY CHANGE: Asio transport socket policy method
`cancel_socket` will now return `lib::asio::error_code` instead of `void`.
Custom Asio transport socket policies will need to be updated accordingly.
This does not affect anyone using the bundled socket policies.
- Feature: Basic support for the permessage-deflate extension. #344
- Feature: Allow accessing the local endpoint when using the Asio transport.
This allows inspection of the address and port in cases where they are chosen
by the operating system rather than the user. Thank you Andreas Weis and
Muzahid Hussain for reporting and related code. #458
- Feature: Add support for subprotocols in Hybi00. Thank you Lukas Obermann
for reporting and a patch. #518
- Feature: Adds `tcp_pre_bind handler` to Asio transport. This allows setting
arbitrary socket options after the listen acceptor has been created but before
the socket bind has been performed. #634 #439 Thank you Gregor Jasny for
the patch.
- Improvement: Better automatic std::chrono feature detection for Visual Studio
- Improvement: Major refactoring to bundled CMake build system. CMake can now be
used to build all of the examples and the test suite. Thank you Thijs Wenker
for a significant portion of this code. #378, #435, #449
- Improvement: In build environments where `lib::error_code` and
`lib::asio::error_code` match (such as using `boost::asio` with
`boost::system_error` or standalone asio with `std::system_error`, transport
errors are passed through natively rather than being reported as a translated
`pass_through` error type.
- Improvement: Add a `get_transport_error` method to Asio transport connections
to allow retrieving a machine readable native transport error.
- Improvement: Add `connection::get_response`, `connection::get_response_code`,
and `connection::get_response_msg` methods to allow accessing additional
information about the HTTP responses that WebSocket++ sends. #465 Thank you
Flow86 for reporting.
- Improvement: Removes use of empty strings ("") in favor of `string::clear()`
and `string::empty()`. This avoids generating unnecessary temporary objects.
#468 Thank you Vladislav Yaroslavlev for reporting and a patch.
- Documentation: Adds an example demonstrating the use of external `io_service`
- Documentation: Adds a simple `echo_client` example.
- Documentation: Begins migration of the web based user manual into Doxygen.
- Bug: Fix memory leak when `init_asio` produces an error. #454 Thank you Mark
Grimes for reporting and fixing.
- Bug: Fix crash when processing a specially crafted HTTP header. Thank you Eli
Fidler for reporting, test cases, and a patch. #456
- Bug: Fix an issue where standalone Asio builds that use TLS would not compile
due to lingering boost code. #448 Thank you mjsp for reporting
- Bug: Fix an issue where canceling a socket could throw an exception on some
older Windows XP platforms. It now prints an appropriate set of log messages
instead. Thank you Thijs Wenker for reporting and researching solutions. #460
- Bug: Fix an issue where deferred HTTP connections that start sending a very
long response before their HTTP handler ends would result in a second set of
HTTP headers being injected into the output. Thank you Kevin Smith for
reporting and providing test case details. #443
- Bug: Fix an issue where the wrong type of strand was being created. Thank you
Bastien Brunnenstein for reporting and a patch. #462
- Bug: Fix an issue where TLS includes were broken for Asio Standalone builds.
Thank you giachi and Bastien Brunnenstein for reporting. #491
- Bug: Remove the use of cached read and write handlers in the Asio transport.
This feature caused memory leaks when the `io_service` the connection was
running on was abruptly stopped. There isn't a clean and safe way of using
this optimization without global state and the associated locks. The locks
perform worse. Thank you Xavier Gibert for reporting, test cases, and code.
Fixes #490.
- Bug: Fix a heap buffer overflow when checking very short URIs. Thank you
Xavier Gibert for reporting and a patch #524
- Compatibility: Fixes a number of build & config issues on Visual Studio 2015
- Compatibility: Removes non-standards compliant masking behavior. #395, #469
- Compatibility: Replace deprecated use of `auto_ptr` on systems where
`unique_ptr` is available.
0.6.0 - 2015-06-02
- MINOR BREAKING TRANSPORT POLICY CHANGE: Custom transport policies will now be
required to include a new method `void set_uri(uri_ptr u)`. An implementation
is not required. The stub transport policy includes an example stub method
that can be added to any existing custom transport policy to fulfill this
requirement. This does not affect anyone using the bundled transports or
configs.
- MINOR BREAKING SOCKET POLICY CHANGE: Custom asio transport socket policies
will now be required to include a new method `void set_uri(uri_ptr u)`. Like
with the transport layer, an implementation is not required. This does not
affect anyone using the bundled socket policies.
- MINOR BREAKING DEPENDENCY CHANGE: When using Boost versions greater than or
equal to 1.49 in C++03 mode, `libboost-chrono` is needed now instead of
`libboost-date_time`. Users with C++11 compilers or using Boost versions 1.48
and earlier are not affected. Note: This change affects the bundled unit test
suite.
- Feature: WebSocket++ Asio transport policy can now be used with the standalone
version of Asio (1.8.0+) when a C++11 compiler and standard library are
present. This means that it is possible now to use WebSocket++'s Asio
transport entirely without Boost. Thank you Robert Seiler for proof of concept
code that was used as a guide for this implementation. Fixes #324
- Feature: Adds a vectored/scatter-gather write handler to the iostream
transport.
- Feature: Adds the ability to defer sending an HTTP response until sometime
after the `http_handler` is run. This allows processing of long running http
handlers to defer their response until it is ready without blocking the
network thread. references #425
- Improvement: `echo_server_tls` has been update to demonstrate how to configure
it for Mozilla's recommended intermediate and modern TLS security profiles.
- Improvement: `endpoint::set_timer` now uses a steady clock provided by
`boost::chrono` or `std::chrono` where available instead of the non-monotonic
system clock. Thank you breyed for reporting. fixes #241
- Improvement: Outgoing TLS connections to servers using the SNI extension to
choose a certificate will now work. Thank you moozzyk for reporting.
Fixes #400
- Improvement: Removes an unnecessary mutex lock in `get_con_from_hdl`.
- Cleanup: Asio transport policy has been refactored to remove many Boost
dependencies. On C++03 compilers the `boost::noncopyable` dependency has been
removed and the `boost::date_time` dependency has been replaced with the newer
`boost::chrono` when possible. On C++11 compilers the `boost::aligned_storage`
and `boost::date_time` dependencies are gone, replaced with equivalent C++11
standard library features.
- Bug: Fixes a potential dangling pointer and inconsistent error message
handling in `websocketpp::exception`. #432 Thank you Tom Swirly for the fix.
0.5.1 - 2015-02-27
- Bug: Fixes an issue where some frame data was counted against the max header
size limit, resulting in connections that included a lot of frame data
immediately after the opening handshake to fail.
- Bug: Fix a typo in the name of the set method for `max_http_body_size`. #406
Thank you jplatte for reporting.
0.5.0 - 2015-01-22
- BREAKING UTILITY CHANGE: Deprecated methods `http::parser::parse_headers`,
`http::response::parse_complete`, and `http::request::parse_complete` have
been removed.
- Security: Disabled SSLv3 in example servers.
- Feature: Adds basic support for accessing HTTP request bodies in the http
handler. #181
- Feature: Adds the ability to register a shutdown handler when using the
iostream transport. This provides a clean interface for triggering the shut
down of external sockets and other cleanup without hooking in to higher level
WebSocket handlers.
- Feature: Adds the ability to register a write handler when using the iostream
transport. This handler can be used to handle transport output in place of
registering an ostream to write to.
- Feature: Adds a new logging policy that outputs to syslog. #386 Thank you Tom
Hughes for submitting the initial version of this policy.
- Improvement: Message payload logging now prints text for text messages rather
than binary.
- Improvement: Overhaul of handshake state machine. Should make it impossible
for exceptions to bubble out of transport methods like `io_service::run`.
- Improvement: Overhaul of handshake error reporting. Fail handler error codes
will be more detailed and precise. Adds new [fail] and [http] logging channels
that log failed websocket connections and successful HTTP connections
respectively. A new aggregate channel package, `alevel::access_core`, allows
enabling connect, disconnect, fail, and http together. Successful HTTP
connections will no longer trigger a fail handler.
- Improvement: Ability to terminate connection during an http handler to cleanly
suppress the default outgoing HTTP response.
- Documentation: Add Sending & Receiving Messages step to chapter one of the
`utility_client` tutorial. Update `utility_client` example to match.
- Cleanup: Removes unused files & STL includes. Adds required STL includes.
Normalizes include order.
- Bug: Fixes a fatal state error when a handshake response is completed
immediately after that handshake times out. #389
- Bug: MinGW fixes; C++11 feature detection, localtime use. #393 Thank you
Schebb for reporting, code, and testing.
- Bug: Fixes an issue where `websocketpp::exception::what()` could return an out
of scope pointer. #397 Thank you fabioang for reporting.
- Bug: Fixes an issue where endpoints were not reset properly after a call to
`endpoint::listen` failed. #390 Thank you wyyqyl for reporting.
0.4.0 - 2014-11-04
- BREAKING API CHANGE: All WebSocket++ methods now throw an exception of type
`websocketpp::exception` which derives from `std::exception`. This normalizes
all exception types under the standard exception hierarchy and allows
WebSocket++ exceptions to be caught in the same statement as others. The error
code that was previously thrown is wrapped in the exception object and can be
accessed via the `websocketpp::exception::code()` method.
- BREAKING API CHANGE: Custom logging policies have some new required
constructors that take generic config settings rather than pointers to
std::ostreams. This allows writing logging policies that do not involve the
use of std::ostream. This does not affect anyone using the built in logging
policies.
- BREAKING UTILITY CHANGE: `websocketpp::lib::net::htonll` and
`websocketpp::lib::net::ntohll` have been prefixed with an underscore to avoid
conflicts with similarly named macros in some operating systems. If you are
using the WebSocket++ provided 64 bit host/network byte order functions you
will need to switch to the prefixed versions.
- BREAKING UTILITY CHANGE: The signature of `base64_encode` has changed from
`websocketpp::base64_encode(unsigned char const *, unsigned int)` to
`websocketpp::base64_encode(unsigned char const *, size_t)`.
- BREAKING UTILITY CHANGE: The signature of `sha1::calc` has changed from
`websocketpp::sha1::calc(void const *, int, unsigned char *)` to
`websocketpp::sha1::calc(void const *, size_t, unsigned char *)`
- Feature: Adds incomplete `minimal_server` and `minimal_client` configs that
can be used to build custom configs without pulling in the dependencies of
`core` or `core_client`. These configs will offer a stable base config to
future-proof custom configs.
- Improvement: Core library no longer has std::iostream as a dependency.
std::iostream is still required for the optional iostream logging policy and
iostream transport.
- Bug: C++11 Chrono support was being incorrectly detected by the `boost_config`
header. Thank you Max Dmitrichenko for reporting and a patch.
- Bug: use of `std::put_time` is now guarded by a unique flag rather than a
chrono library flag. Thank you Max Dmitrichenko for reporting.
- Bug: Fixes non-thread safe use of std::localtime. #347 #383
- Compatibility: Adjust usage of std::min to be more compatible with systems
that define a min(...) macro.
- Compatibility: Removes unused parameters from all library, test, and example
code. This assists with those developing with -Werror and -Wunused-parameter
#376
- Compatibility: Renames ntohll and htonll methods to avoid conflicts with
platform specific macros. #358 #381, #382 Thank you logotype, unphased,
svendjo
- Cleanup: Removes unused functions, fixes variable shadow warnings, normalizes
all whitespace in library, examples, and tests to 4 spaces. #376
0.3.0 - 2014-08-10
- Feature: Adds `start_perpetual` and `stop_perpetual` methods to asio transport
These may be used to replace manually managed `asio::io_service::work` objects
- Feature: Allow setting pong and handshake timeouts at runtime.
- Feature: Allows changing the listen backlog queue length.
- Feature: Split tcp init into pre and post init.
- Feature: Adds URI method to extract query string from URI. Thank you Banaan
for code. #298
- Feature: Adds a compile time switch to asio transport config to disable
certain multithreading features (some locks, asio strands)
- Feature: Adds the ability to pause reading on a connection. Paused connections
will not read more data from their socket, allowing TCP flow control to work
without blocking the main thread.
- Feature: Adds the ability to specify whether or not to use the `SO_REUSEADDR`
TCP socket option. The default for this value has been changed from `true` to
`false`.
- Feature: Adds the ability to specify a maximum message size.
- Feature: Adds `close::status::get_string(...)` method to look up a human
readable string given a close code value.
- Feature: Adds `connection::read_all(...)` method to iostream transport as a
convenience method for reading all data into the connection buffer without the
end user needing to manually loop on `read_some`.
- Improvement: Open, close, and pong timeouts can be disabled entirely by
setting their duration to 0.
- Improvement: Numerous performance improvements. Including: tuned default
buffer sizes based on profiling, caching of handler binding for async
reads/writes, non-malloc allocators for read/write handlers, disabling of a
number of questionably useful range sanity checks in tight inner loops.
- Improvement: Cleaned up the handling of TLS related errors. TLS errors will
now be reported with more detail on the info channel rather than all being
`tls_short_read` or `pass_through`. In addition, many cases where a TLS short
read was in fact expected are no longer classified as errors. Expected TLS
short reads and quasi-expected socket shutdown related errors will no longer
be reported as unclean WebSocket shutdowns to the application. Information
about them will remain in the info error channel for debugging purposes.
- Improvement: `start_accept` and `listen` errors are now reported to the caller
either via an exception or an ec parameter.
- Improvement: Outgoing writes are now batched for improved message throughput
and reduced system call and TCP frame overhead.
- Bug: Fix some cases of calls to empty lib::function objects.
- Bug: Fix memory leak of connection objects due to cached handlers holding on to
reference counted pointers. #310 Thank you otaras for reporting.
- Bug: Fix issue with const endpoint accessors (such as `get_user_agent`) not
compiling due to non-const mutex use. #292 Thank you logofive for reporting.
- Bug: Fix handler allocation crash with multithreaded `io_service`.
- Bug: Fixes incorrect whitespace handling in header parsing. #301 Thank you
Wolfram Schroers for reporting
- Bug: Fix a crash when parsing empty HTTP headers. Thank you Thingol for
reporting.
- Bug: Fix a crash following use of the `stop_listening` function. Thank you
Thingol for reporting.
- Bug: Fix use of variable names that shadow function parameters. The library
should compile cleanly with -Wshadow now. Thank you giszo for reporting. #318
- Bug: Fix an issue where `set_open_handshake_timeout` was ignored by server
code. Thank you Robin Rowe for reporting.
- Bug: Fix an issue where custom timeout values weren't being propagated from
endpoints to new connections.
- Bug: Fix a number of memory leaks related to server connection failures. #323
#333 #334 #335 Thank you droppy and aydany for reporting and patches.
reporting.
- Compatibility: Fix compile time conflict with Visual Studio's MIN/MAX macros.
Thank you Robin Rowe for reporting.
- Documentation: Examples and test suite build system now defaults to clang on
OS X
0.3.0-alpha4 - 2013-10-11
- HTTP requests ending normally are no longer logged as errors. Thank you Banaan
for reporting. #294
- Eliminates spurious expired timers in certain error conditions. Thank you
Banaan for reporting. #295
- Consolidates all bundled library licenses into the COPYING file. #294
- Updates bundled sha1 library to one with a cleaner interface and more
straight-forward license. Thank you lotodore for reporting and Evgeni Golov
for reviewing. #294
- Re-introduces strands to asio transport, allowing `io_service` thread pools to
be used (with some limitations).
- Removes endpoint code that kept track of a connection list that was never used
anywhere. Removes a lock and reduces connection creation/deletion complexity
from O(log n) to O(1) in the number of connections.
- A number of internal changes to transport APIs
- Deprecates iostream transport `readsome` in favor of `read_some` which is more
consistent with the naming of the rest of the library.
- Adds preliminary signaling to iostream transport of eof and fatal transport
errors
- Updates transport code to use shared pointers rather than raw pointers to
prevent asio from retaining pointers to connection methods after the
connection goes out of scope. #293 Thank you otaras for reporting.
- Fixes an issue where custom headers couldn't be set for client connections
Thank you Jerry Win and Wolfram Schroers for reporting.
- Fixes a compile error on visual studio when using interrupts. Thank you Javier
Rey Neira for reporting this.
- Adds new 1012 and 1013 close codes per IANA registry
- Add `set_remote_endpoint` method to iostream transport.
- Add `set_secure` method to iostream transport.
- Fix typo in .gitattributes file. Thank you jstarasov for reporting this. #280
- Add missing locale include. Thank you Toninoso for reporting this. #281
- Refactors `asio_transport` endpoint and adds full documentation and exception
free varients of all methods.
- Removes `asio_transport` endpoint method cancel(). Use `stop_listen()` instead
- Wrap internal `io_service` `run_one()` method
- Suppress error when trying to shut down a connection that was already closed
0.3.0-alpha3 - 2013-07-16
- Minor refactor to bundled sha1 library
- HTTP header comparisons are now case insensitive. #220, #275
- Refactors URI to be exception free and not use regular expressions. This
eliminates the dependency on boost or C++11 regex libraries allowing native
C++11 usage on GCC 4.4 and higher and significantly reduces staticly built
binary sizes.
- Updates handling of Server and User-Agent headers to better handle custom
settings and allow suppression of these headers for security purposes.
- Fix issue where pong timeout handler always fired. Thank you Steven Klassen
for reporting this bug.
- Add ping and pong endpoint wrapper methods
- Add `get_request()` pass through method to connection to allow calling methods
specific to the HTTP policy in use.
- Fix issue compile error with `WEBSOCKETPP_STRICT_MASKING` enabled and another
issue where `WEBSOCKETPP_STRICT_MASKING` was not applied to incoming messages.
Thank you Petter Norby for reporting and testing these bugs. #264
- Add additional macro guards for use with boost_config. Thank you breyed
for testing and code. #261
0.3.0-alpha2 - 2013-06-09
- Fix a regression that caused servers being sent two close frames in a row
to end a connection uncleanly. #259
- Fix a regression that caused spurious frames following a legitimate close
frames to erroneously trigger handlers. #258
- Change default HTTP response error code when no http_handler is defined from
500/Internal Server Error to 426/Upgrade Required
- Remove timezone from logger timestamp to work around issues with the Windows
implementation of strftime. Thank you breyed for testing and code. #257
- Switch integer literals to char literals to improve VCPP compatibility.
Thank you breyed for testing and code. #257
- Add MSVCPP warning suppression for the bundled SHA1 library. Thank you breyed
for testing and code. #257
0.3.0-alpha1 - 2013-06-09
- Initial Release
+112
View File
@@ -0,0 +1,112 @@
# Print build configuration
macro (print_used_build_config)
message ("\n=========== Used Build Configuration =============\n")
message (STATUS "ENABLE_CPP11 = " ${ENABLE_CPP11})
message (STATUS "BUILD_EXAMPLES = " ${BUILD_EXAMPLES})
message (STATUS "BUILD_TESTS = " ${BUILD_TESTS})
message ("")
message (STATUS "WEBSOCKETPP_ROOT = " ${WEBSOCKETPP_ROOT})
message (STATUS "WEBSOCKETPP_BIN = " ${WEBSOCKETPP_BIN})
message (STATUS "WEBSOCKETPP_LIB = " ${WEBSOCKETPP_LIB})
message (STATUS "Install prefix = " ${CMAKE_INSTALL_PREFIX})
message ("")
message (STATUS "WEBSOCKETPP_BOOST_LIBS = ${WEBSOCKETPP_BOOST_LIBS}")
message (STATUS "WEBSOCKETPP_PLATFORM_LIBS = ${WEBSOCKETPP_PLATFORM_LIBS}")
message (STATUS "WEBSOCKETPP_PLATFORM_TLS_LIBS = ${WEBSOCKETPP_PLATFORM_TLS_LIBS}")
message ("")
message (STATUS "OPENSSL_FOUND = ${OPENSSL_FOUND}")
message (STATUS "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}")
message (STATUS "OPENSSL_LIBRARIES = ${OPENSSL_LIBRARIES}")
message (STATUS "OPENSSL_VERSION = ${OPENSSL_VERSION}")
message ("")
endmacro ()
# Adds the given folder_name into the source files of the current project.
# Use this macro when your module contains .cpp and .h files in several subdirectories.
# Your sources variable needs to be WSPP_SOURCE_FILES and headers variable WSPP_HEADER_FILES.
macro(add_source_folder folder_name)
file(GLOB H_FILES_IN_FOLDER_${folder_name} ${folder_name}/*.hpp ${folder_name}/*.h)
file(GLOB CPP_FILES_IN_FOLDER_${folder_name} ${folder_name}/*.cpp ${folder_name}/*.c)
source_group("Header Files\\${folder_name}" FILES ${H_FILES_IN_FOLDER_${folder_name}})
source_group("Source Files\\${folder_name}" FILES ${CPP_FILES_IN_FOLDER_${folder_name}})
set(WSPP_HEADER_FILES ${WSPP_HEADER_FILES} ${H_FILES_IN_FOLDER_${folder_name}})
set(WSPP_SOURCE_FILES ${WSPP_SOURCE_FILES} ${CPP_FILES_IN_FOLDER_${folder_name}})
endmacro()
# Initialize target.
macro (init_target NAME)
set (TARGET_NAME ${NAME})
message ("** " ${TARGET_NAME})
# Include our own module path. This makes #include "x.h"
# work in project subfolders to include the main directory headers.
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
endmacro ()
# Build executable for executables
macro (build_executable TARGET_NAME)
set (TARGET_LIB_TYPE "EXECUTABLE")
message (STATUS "-- Build Type:")
message (STATUS " " ${TARGET_LIB_TYPE})
add_executable (${TARGET_NAME} ${ARGN})
include_directories (${WEBSOCKETPP_ROOT} ${WEBSOCKETPP_INCLUDE})
target_link_libraries(${TARGET_NAME} ${WEBSOCKETPP_PLATFORM_LIBS})
set_target_properties (${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${WEBSOCKETPP_BIN})
set_target_properties (${TARGET_NAME} PROPERTIES DEBUG_POSTFIX d)
endmacro ()
# Build executable and register as test
macro (build_test TARGET_NAME)
build_executable (${TARGET_NAME} ${ARGN})
if (${CMAKE_VERSION} VERSION_LESS 3)
message(WARNING "CMake too old to register ${TARGET_NAME} as a test")
else ()
add_test(NAME ${TARGET_NAME} COMMAND $<TARGET_FILE:${TARGET_NAME}>)
endif ()
endmacro ()
# Finalize target for all types
macro (final_target)
if ("${TARGET_LIB_TYPE}" STREQUAL "EXECUTABLE")
install (TARGETS ${TARGET_NAME}
RUNTIME DESTINATION "bin"
CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})
endif ()
# install headers, directly from current source dir and look for subfolders with headers
file (GLOB_RECURSE TARGET_INSTALL_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.hpp)
foreach (hppfile ${TARGET_INSTALL_HEADERS})
get_filename_component (currdir ${hppfile} PATH)
install (FILES ${hppfile} DESTINATION "include/${TARGET_NAME}/${currdir}")
endforeach()
endmacro ()
macro (link_boost)
target_link_libraries (${TARGET_NAME} ${Boost_LIBRARIES})
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR})
endmacro ()
macro (link_openssl)
target_link_libraries (${TARGET_NAME} ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${OPENSSL_INCLUDE_DIR})
endmacro ()
macro (link_zlib)
target_link_libraries (${TARGET_NAME} ${ZLIB_LIBRARIES})
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR})
endmacro ()
macro (include_subdirs PARENT)
file (GLOB SDIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PARENT}/*")
foreach (SUBDIR ${SDIRS})
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/CMakeLists.txt")
add_subdirectory ("${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}")
endif ()
endforeach ()
endmacro()
+138
View File
@@ -0,0 +1,138 @@
/** \page reference.config Config Reference
WebSocket++ uses a config template parameter to supply a number of compile type policy types and default numerical values for buffer sizes, timeouts, security behavior, etc. Swapping policies allows changing certain core library behavior designed to be pluggable.
A custom config can be made standalone or can subclass one of the bundled configs and just override a few things.
__Example__
```
// some config options may require additional includes or dependencies.
// syslog logging policy, for example, requires <syslog.h>,
// the permessage deflate settings require zlib.
#include <websocketpp/logger/syslog.hpp>
#include <websocketpp/extensions/permessage_deflate/enabled.hpp>
// Custom server config based on bundled asio config
struct custom_server_config : public websocketpp::config::asio {
// Replace default stream logger with a syslog logger
typedef websocketpp::log::syslog<concurrency_type, websocketpp::log::elevel> elog_type;
typedef websocketpp::log::syslog<concurrency_type, websocketpp::log::alevel> alog_type;
// Reduce read buffer size to optimize for small messages
static const size_t connection_read_buffer_size = 1024;
// enable permessage_compress extension
struct permessage_deflate_config {};
typedef websocketpp::extensions::permessage_deflate::enabled
<permessage_deflate_config> permessage_deflate_type;
};
typedef websocketpp::server<custom_server_config> server_endpoint_type;
```
Core Config Options
-------------------
### Policies
Policies are classes used to allow clean swapping of behavior without changing the core library
| Typedef Name | Effect |
| ------------------------- | -------------------------------------- |
| concurrency_type | Concurrency policy |
| elog_type | Error logger type |
| alog_type | Access logger type |
| request_type | HTTP request type |
| response_type | HTTP response type |
| message_type | Type to deliver recieved messages |
| con_msg_manager_type | Connection level message manager |
| endpoint_msg_manager_type | Endpoint level message manager |
| rng_type | Random Number Generation policy |
| transport_type | Transport policy to use |
| endpoint_base | User overridable Endpoint base class |
| connection_base | User overridable Connection base class |
### Timeouts Values
These represent the length of time (in ms) before the given operation is aborted
| Field | Type | Default | Operation |
| ----------------------- | ---- | ------- | --------------------------- |
| timeout_open_handshake | long | 5000 | Opening handshake |
| timeout_close_handshake | long | 5000 | Closing handshake |
| timeout_pong | long | 5000 | No pong recieved after ping |
### Performance tuning
| Field | Type | Default | Meaning |
| --------------------------- | ------ | -------- | ------------------------------------------------------------------ |
| connection_read_buffer_size | size_t | 16384 | Size of the per-connection read buffer |
| enable_multithreading | bool | true | Disabling may reduce locking overhead for single threaded programs |
#### Connection Read Buffer
Each connection has an internal buffer of this size. A larger value will result in fewer trips through the library and less CPU overhead at the expense of increased memory usage per connection.
If your application primarily deals in very large messages you may want to try setting this value higher.
If your application has a lot of connections or primarily deals in small messages you may want to try setting this smaller.
### Security settings
| Field | Type | Default | Effect |
| ---------------------- | ------ | ------- | -------------------------------------- |
| drop_on_protocol_error | bool | false | Omit close handshake on protocol error |
| silent_close | bool | false | Don't return close codes or reasons |
| max_message_size | size_t | 32MB | WebSocket max message size limit |
| max_http_body_size | size_t | 32MB | HTTP Parser's max body size limit |
#### Drop on protocol error
Drop connections on protocol error rather than sending a close frame. Off by default. This may result in legitimate messages near the error being dropped as well. It may free up resources otherwise spent dealing with misbehaving clients.
#### Silent Close
Silence close suppresses the return of detailed connection close information during the closing handshake. This information is useful for debugging and presenting useful errors to end users but may be undesirable for security reasons in some production environments. Close reasons could be used by an attacker to confirm that the endpoint is out of resources or be used to identify the WebSocket implementation in use.
Note: this will suppress *all* close codes, including those explicitly sent by local applications.
#### Max message size
Default value for the processor's maximum message size. Maximum message size determines the point at which the library will drop a connection with the message_too_big protocol error.
#### Max HTTP header size
Maximum body size determines the point at which the library will abort reading an HTTP message body and return the 413/request entity too large error.
Transport Config Options
------------------------
### Policies
Policies are classes used to allow clean swapping of behavior without changing the core library
| Typedef Name | Effect |
| ---------------- | ------------------ |
| concurrency_type | Concurrency Policy |
| elog_type | Error logger type |
| alog_type | Access logger type |
| request_type | HTTP request type |
| response_type | HTTP response type |
### Timeouts Values
These represent the length of time (in ms) before the given operation is aborted
| Field | Type | Default | Operation |
| ------------------------ | ---- | ------- | --------------------------------------------- |
| timeout_socket_pre_init | long | 5000 | Transport dependent |
| timeout_proxy | long | 5000 | Proxy handshake |
| timeout_socket_post_init | long | 5000 | Transport dependent (commonly: TLS handshake) |
| timeout_dns_resolve | long | 5000 | DNS resolution |
| timeout_connect | long | 5000 | TCP Connect |
| timeout_socket_shutdown | long | 5000 | Socket shutdown |
### Performance tuning
| Field | Type | Default | Meaning |
| --------------------------- | ------ | -------- | ------------------------------------------------------------------ |
| enable_multithreading | bool | true | Disabling may reduce locking overhead for single threaded programs |
*/
+162
View File
@@ -0,0 +1,162 @@
/** \page faq FAQ
## General Library Usage
### Can a handler be changed after a connection is established? Can one be removed?
Yes, but not globally.
Handlers assigned to endpoints will be automatically copied to the connections created by that endpoint. Changing a handler on an endpoint will only affect future connections.
Once a particular connection is created, it's handlers can be changed individually by calling the `set_*_handler` methods. Once changed, all future events of that type for that connection will use the new handler.
To remove a handler that was previously set, call the set method with `nullptr` or `NULL`.
### Can I reject or conditionally accept a connection
Yes. The `validate` handler is called after the initial handshake has been recieved but before WebSocket++ has responded. This gives you the opportunity to inspect the incoming connection request, its headers, origin, subprotocols, and the remote endpoint IP. Return `true` from the validate handler to accept the connection and `false` to reject it.
To set a custom HTTP error message for your rejection, use `websocketpp::connection::set_status` and (optionally) `websocketpp::connection::set_body()` to set the HTTP status code and error message body text. If you do not set body text a message will be generated automatically based on the status code.
### How do I negotiate subprotocols?
WebSocket connections may offer a particular subprotocol they want to use. The WebSocket protocol does not define the meaning or interpretation of the subprotocol. This interpretation is left up to the individual application endpoints.
WebSocket++ servers can read the requested subprotocols during the `validate` handler by calling `websocketpp::connection::get_requested_subprotocols`. The list is ordered by client priority. You may optionally choose one of these subprotocols with `websocketpp::connection::select_subprotocol`. The handshake will then complete and let the client know which one was chosen. If you do not choose any, the "blank"/empty/none subprotocol will be used.
WebSocket++ clients can add a subprotocol to an outgoing connection by calling `websocketpp::connection::add_subprotocol` before calling `websocketpp::client::connect`. The order of adding will be interpreted as the order of preference.
In both caases, after the connection has been established, the selected subprotocol is available via the `websocketpp::connection::get_subprotocol` method.
Note: some browsers will allow the connection to continue if they requested a subprotocol and your server doesn't select one. Others will reject the connection.
### How do I cleanly exit an Asio transport based program
The Asio transport based clients and servers use the Asio library's underlying `io_service` to handle asyncronous networking operations. The standard behavior of the io_service is to run until there are no async operations left and then return. WebSocket++, when using the Asio transport, behaves like a standard Asio application. If you want your WebSocket++/Asio based program to stop network operations and cleanly close all sockets you will want to do the following:
- For servers, call `websocketpp::transport::asio::endpoint::stop_listening` to initiate the closing of the server listening socket.
- For clients, if you have engaged perpetual mode with `websocketpp::transport::asio::endpoint::start_perpetual`, disable it with `websocketpp::transport::asio::endpoint::stop_perpetual`.
- For both, run `websocketpp::endpoint::close` or `websocketpp::connection::close` on all currently outstanding connections. This will initiate the WebSocket closing handshake for these connections
- Wait. Asio is asyncronous. When the calls to the above methods (stop_listening, close, etc) complete the server *will still be listening*, the connections *will still be active* until the io_service gets around to asyncronously processing the socket and WebSocket protocol closing handshakes. The `io_service::run` method will exit cleanly and automatically when all operations are complete.
__WARNING__: Asio's `io_service` has a method called `stop`. WebSocket++ wraps this method as `websocketpp::transport::asio::endpoint::stop`. While this operation has a benign sounding name, it is a powerful and destructive operation that should only be used in special cases. If you are using `io_service::stop` or `endpoint::stop` without a very good reason your program is likely broken and may exhibit erratic behavior. Specifically, `io_service::stop` stops the processing of events entirely. This does not give current operations (such as socket closing handshakes) the opportunity to finish. It will leave your sockets in a dangling state that may invoke operating system level timeouts or other errors.
__Special cases__:
- If your client uses the `start_perpetual` method it will prevent the io_service from exiting even if it has nothing to do. This is useful if you want a client endpoint to idle in the background to allow new connections to be formed on demand rather than generating a new endpoint for each.
- If you are using an external io_service and/or are placing non-WebSocket++ operations on the `io_service` those operations may keep the `io_service` open even after all WebSocket++ operations have completed.
- If you are using `poll`/`poll_one`/`run_one` or otherwise manually driving the `io_service` event loop you may need to adjust usage to make sure you are correctly recognizing the "done with work" and "not done but idling / `io_service::work`" cases.
### Is there a way to check the validity of a `connection_hdl`?
Sometimes, not generally though, because there isnt a way to check if a TCP connection is valid.
You can try upgrading your hdl to a full connection_ptr using `websocketpp::endpoint::get_con_from_hdl`. If this fails, the hdl is definitely invalid. If it succeeds it may or may not be. The only way to tell definitively is to try and send something (either a message or a ping).
If you handle errors from methods like send, ping, close, etc correctly then you shouldnt have to worry about accidentally sending to dead connections. The send/ping/pong/close methods will set or throw a specific error in the case that you tried to send something but the connection was closed/gone/etc.
### How do I fix the "address is in use" error when trying to restart my server?
Normally, for security purposes, operating systems prevent programs from listening on sockets created by other programs. When your program crashes and restarts, the new instance is a different program from the perspective of the operating system. As such it cant listen on the socket address/port that the previous program was using until after a timeout occurs to make sure the old program was done with it.
The the first step for handling this is to make sure that you provide a method (signal handler, admin websocket message, etc) to perform a clean server shutdown. There is a question elsewhere in this FAQ that describes the steps necessary for this.
The clean close strategy won't help in the case of crashes or other abnormal closures. An option to consider for these cases is the use of the SO_REUSEADDR socket option. This instructs the OS to not request an exclusive lock on the socket. This means that after your program crashes the replacement you start can immediately listen on that address/port combo again.
__Please note__: how this works exactly depends on your operating system. Additionally, not exclusively locking your listening socket could allow hijacking by other programs if you are running in a shared resource environment. For development this is generally no problem. For a production environment, think carefully about the security model. `websocketpp::transport::asio::endpoint::set_reuse_addr` is the method to do this. You must specify this setting before calling `websocketpp::transport::asio::endpoint::listen`.
### How do I send and recieve binary messages?
When supported by the remote endpoint, WebSocket++ allows reading and sending messages in the two formats specified in RFC6455, UTF8 text and binary. WebSocket++ performs UTF8 validation on all outgoing text messages to ensure that they meet the specification. Binary messages do not have any additional processing and their interpretation is left entirely to the library user.
To determine the type of an incoming message, use `websocketpp::message_buffer::message::get_opcode`. The relevant return values are `websocketpp::frame::opcode::text` and `websocketpp::frame::opcode::binary`. There is no difference in how payloads are retrieved between these modes, only in how WebSocket++ validated the contents and how the library user is to interpret the data.
To specify the type of an outgoing message, use the frame opcode values listed above as the second op parameter for `websocketpp::connection::send`. There are two relevant overloads of send. One that takes a `std::string` and defaults to op=text. The other that takes a `void const *` and a `size_t` length and defaults to op=binary. Note: You can send binary messages via the string overload and text messages via the void * overload. In the case that you are manually building a message buffer rather than using the automatic send member functions, you can pass the opcode in as a parameter to the message buffer constructor or user the `websocketpp::message_buffer::message::set_opcode` member function to set or re-set it later.
## Dependency Management
### Can WebSocket++ be used without Boost?
Yes. WebSocket++ only uses Boost features as polyfills for C++11 language features and libraries. If you have a C++11 compiler and standard library you can use WebSocket++ without Boost. In most cases setting your build environment to use the C++11 (or later) language dialect is sufficient to enable this mode of use.
With less common compilers (and sometimes very recently release compilers) there may be specific issues with certain libraries that aren't automatically detected by the library. For these situations there are additional defines available to fine tune which C++11 libraries and features are used. TODO: more details about them.
For the iostream/raw transport the C++11 standard library is sufficient. For the Asio based transports, there is no C++11 library that provides the networking capabilaties that Asio does. As such even with a C++11 build system, you will need a standalone copy of Asio to use if Boost Asio is not available.
MinGW users who want to avoid Boost should also consult the nearby question about MinGW compatibility.
### Can WebSocket++ be used with standalone Asio
Yes. The process is the same as used with standalone Asio itself. Define `ASIO_STANDALONE` before including Asio or WebSocket++ headers. You will need to download a copy of the Asio headers separately (http://www.think-async.com) and make sure they are in your build system's include path.
### Can WebSocket++ be used without TLS or OpenSSL?
Yes. When using the iostream/raw transport, there are no TLS features and OpenSSL is not required. When using the Asio transport TLS features are optional. You only need OpenSSL if you want to use TLS. You can only make or recieve encrypted connections (https/wss) if you have enabled TLS features.
Whether an Asio endpoint uses TLS or not is determined by its config template parameter. The default bundled `websocketpp::config::asio` and `websocketpp::config::asio_client` configs do not support TLS, the `websocketpp::config::asio_tls` and `websocketpp::config::asio_tls_client` do.
The `<websocketpp/config/asio.hpp>` and `<websocketpp/config/asio_client.hpp>` headers will include both the TLS and non-TLS varients of their respective configs and require the presence of OpenSSL. The `<websocketpp/config/asio_no_tls.hpp>` and `<websocketpp/config/asio_no_tls_client.hpp>` headers will include only the non-TLS configs and do not require OpenSSL.
### Build issues with TLS on recent versions of OS X
Mac OS X ships a severely outdated version of the OpenSSL library. To securely use TLS with WebSocket++ on OS X you will need to install a modern version of OpenSSL via homebrew or compiling from source.
### Can WebSocket++ be used with MinGW
Generally, yes. Note that in C++11 mode MinGW does not currently support the C++11 STL `<thread>` library. WebSocket++ requires a thread/mutex library. Options include Boost thread (the default when a compatible C++11 `<thread>` can't be found) or `mingw-std-threads` (https://github.com/meganz/mingw-std-threads) by including those headers and defining `_WEBSOCKETPP_MINGW_THREAD_`.
## Compression
### How do I use permessage-deflate in version 0.6.0-permessagedeflate and 0.7.0?
These versions of the library require a custom config to use the permessage-deflate extension. Here is a minimal example of such a custom config. You can also integrate these lines into an existing custom config.
Note that in these versions there is no fine grained control over which connections are compressed or not. Clients will request compression with the default settings and use it if the server supports it. Servers will accept whatever parameters clients request.
Outgoing messages by default will be compressed if compression was auto-negotiated during the handshake. There is an option to force a specific message to be sent uncompressed even if compression was negotiated. This may be useful for sending data that you know to be compressed already (images, zip files, etc).
__Server Example__
```
#include <websocketpp/extensions/permessage_deflate/enabled.hpp>
struct deflate_server_config : public websocketpp::config::asio {
// ... additional custom config if you need it for other things
/// permessage_compress extension
struct permessage_deflate_config {};
typedef websocketpp::extensions::permessage_deflate::enabled
<permessage_deflate_config> permessage_deflate_type;
};
typedef websocketpp::server<deflate_server_config> server_endpoint_type;
```
__Client Example__
```
#include <websocketpp/extensions/permessage_deflate/enabled.hpp>
struct deflate_client_config : public websocketpp::config::asio_client {
// ... additional custom config if you need it for other things
/// permessage_compress extension
struct permessage_deflate_config {};
typedef websocketpp::extensions::permessage_deflate::enabled
<permessage_deflate_config> permessage_deflate_type;
};
typedef websocketpp::client<deflate_client_config> client_endpoint_type;
```
## Security
### Is it possible to terminate a malicious connection quickly, without tying up resources performing clean close steps,
Yes. The library will automatically detect and terminate connections that violate the WebSocket protocol. In cases where the library believes the remote endpoint to be malicious or sufficiently broken to be unlikely to understand or process the closing handshake, it will be omited.
If your application detects conditions above the protocol level that you believe to be malicious, for example, if you recognize an IP from a known denial of service attack, you can close the connection with two different levels of urgency. Use the standard `websocketpp::endpoint::close` or `websocketpp::connection::close` methods with one of the following special close codes:
- `websocketpp::close::status::omit_handshake`: Omits the closing handshake, but cleanly closes the TCP connection.
- `websocketpp::close::status::force_tcp_drop`: Forcibly drop the TCP connection.
Please note that usage of these disconnect methods results in a violation of the WebSocket protocol and may have negative reprocusions for the remote endpoint with respect to network timeouts. Please use caution when using them.
## Build Issues
### Getting compile errors related to `std::chrono`, `boost::chrono`, `waitable_timer`, or `steady_clock`
Your build system may be confused about whether it is supposed to be using `boost::chrono` or `std::chrono`. Boost automatically detects this setup on some compilers but not others. Defining `BOOST_ASIO_HAS_STD_CHRONO` can help. See http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/overview/cpp2011/chrono.html for more details.
*/
+27
View File
@@ -0,0 +1,27 @@
/** \page getting_started Getting Started
WebSocket++ code is available on github at https://github.com/zaphoyd/websocketpp
The official project homepage lives at http://www.zaphoyd.com/websocketpp
The git repository is organized into several directories:
- **docs**: This documentation
- **examples**: Example programs that demonstrate how to build basic versions of some commonly used patterns for WebSocket clients and servers.
- **test**: Unit tests that confirm that the code you have works properly and help detect platform specific issues.
- **tutorials**: Detailed walkthroughs of a select set of the example programs.
- **websocketpp**: All of the library code and default configuration files.
WebSocket++ is a header only library. You can start using it by including the websocketpp source directory in your project's include path and including the appropriate WebSocket++ headers in your program. You may also need to include and/or link to appropriate Boost/system libraries. TODO: More information: Building a program with WebSocket++, Walkthroughs of the example programs
WebSocket++ includes cmake and scons scripts for building the examples and unit tests. Neither system is needed unless you want to build tests or examples in an automated fashion.
__Usage questions__ should be posted to the project mailing list at http://groups.google.com/group/websocketpp/ or the IRC channel (\#websocketpp on freenode).
__Bugs and issues__ should be posted to the project GitHub issues queue: https://github.com/zaphoyd/websocketpp/issues.
__Pull requests__ on GitHub are welcome. Please make them against the `develop` branch.
WebSocket++ is written and maintained by Peter Thorson. You can contact me via GitHub messaging, IRC, or via email at websocket@zaphoyd.com.
*/
+165
View File
@@ -0,0 +1,165 @@
/** \page reference.handlers Handler Reference
Handlers allow WebSocket++ programs to receive notifications about events
that happen in relation to their connections. Some handlers also behave as
hooks that give the program a chance to modify state or adjust settings before
the connection continues.
Handlers are registered by calling the appropriate `set_*_handler` method on either an
endpoint or connection. The * refers to the name of the handler (as
specified in the signature field below). For example, to set the open handler,
call `set_open_handler(...)`.
Setting handlers on an endpoint will result in them being copied as the default
handler to all new connections created by that endpoint. Changing an endpoint's
handlers will not affect connections that are already in progress. This includes
connections that are in the listening state. As such, it is important to set any
endpoint handlers before you call `endpoint::start_accept` or else the handlers
will not be attached to your first connection.
Setting handlers on a connection will result in the handler being changed for
that connection only, starting at the next time that handler is called. This can
be used to change the handler during a connection.
Connection Handlers
-------------------
These handlers will be called at most once per connection in the order specified below.
### Socket Init Handler
| Event | Signature | Availability |
| --------------------- | ----------------------------------------------------- | -------------------- |
| Socket initialization | `socket_init(connection_hdl, asio::ip::tcp::socket&)` | 0.3.0 Asio Transport |
This hook is triggered after the socket has been initialized but before a connection is established.
It allows setting arbitrary socket options before connections are sent/recieved.
### TCP Pre-init Handler
| Event | Signature | Availability |
| ----------------------------- | ------------------------------ | -------------------- |
| TCP established, no data sent | `tcp_pre_init(connection_hdl)` | 0.3.0 Asio Transport |
This hook is triggered after the TCP connection is established, but before any pre-WebSocket-handshake
operations have been run. Common pre-handshake operations include TLS handshakes and proxy connections.
### TCP Post-init Handler
| Event | Signature | Availability |
| ----------------------- | ------------------------------------------ | ----------------------------- |
| Request for TLS context | `tls_context_ptr tls_init(connection_hdl)` | 0.3.0 Asio Transport with TLS |
This hook is triggered before the TLS handshake to request the TLS context to use. You must
return a pointer to a configured TLS conext to continue. This provides the opportuinity to
set up the TLS settings, certificates, etc.
### Validate Handler
| Event | Signature | Availability |
| ------------------------------------- | ------------------------------- | ---------------------------- |
| Hook to accept or reject a connection | `bool validate(connection_hdl)` | 0.3.0 Core, Server role only |
This hook is triggered for servers during the opening handshake after the request has been
processed but before the response has been sent. It gives a program the opportunity to inspect
headers and other connection details and either accept or reject the connection. Validate happens
before the open or fail handler.
Return true to accept the connection, false to reject. If no validate handler is registered,
all connections will be accepted.
### Open Connection Handler
| Event | Signature | Availability |
| ------------------------- | ---------------------- | ------------ |
| Successful new connection | `open(connection_hdl)` | 0.3.0 Core |
Either open or fail will be called for each connection. Never both. All
connections that begin with an open handler call will also have a matching
close handler call when the connection ends.
### Fail Connection Handler
| Event | Signature | Availability |
| ----------------------------------- | ---------------------- | ------------ |
| Connection failed (before opening) | `fail(connection_hdl)` | 0.3.0 Core |
Either open or fail will be called for each connection. Never both. Connections
that fail will never have a close handler called.
### Close Connection Handler
| Event | Signature | Availability |
| --------------------------------- | ----------------------- | ------------ |
| Connection closed (after opening) | `close(connection_hdl)` | 0.3.0 Core |
Close will be called exactly once for every connection that open was called for.
Close is not called for failed connections.
Message Handlers
----------------
These handers are called in response to incoming messages or message like events. They only will be called while the connection is in the open state.
### Message Handler
| Event | Signature | Availability |
| --------------------- | -------------------------------------- | ------------ |
| Data message recieved | `message(connection_hdl, message_ptr)` | 0.3.0 Core |
Applies to all non-control messages, including both text and binary opcodes. The
`message_ptr` type and its API depends on your endpoint type and its config.
### Ping Handler
| Event | Signature | Availability |
| ------------- | ---------------------------------------- | ------------ |
| Ping recieved | `bool ping(connection_hdl, std::string)` | 0.3.0 Core |
Second (string) argument is the binary ping payload. Handler return value
indicates whether or not to respond to the ping with a pong. If no ping handler
is set, WebSocket++ will respond with a pong containing the same binary data as
the ping (Per requirements in RFC6455).
### Pong Handler
| Event | Signature | Availability |
| ------------- | ----------------------------------- | ------------ |
| Pong recieved | `pong(connection_hdl, std::string)` | 0.3.0 Core |
Second (string) argument is the binary pong payload.
### Pong Timeout Handler
| Event | Signature | Availability |
| ---------------------------------- | ------------------------------------------- | ---------------------------------------- |
| Timed out while waiting for a pong | `pong_timeout(connection_hdl, std::string)` | 0.3.0 Core, transport with timer support |
Triggered if there is no response to a ping after the configured duration. The second
(string) argument is the binary payload of the unanswered ping.
### HTTP Handler
| Event | Signature | Availability |
| --------------------- | --------------------- | ---------------------------- |
| HTTP request recieved | `http(connection_hdl` | 0.3.0 Core, Server role only |
Called when HTTP requests that are not WebSocket handshake upgrade requests are
recieved. Allows responding to regular HTTP requests. If no handler is registered
a 426/Upgrade Required error is returned.
### Interrupt Handler
| Event | Signature | Availability |
| ----------------------------------- | --------------------------- | ------------ |
| Connection was manually interrupted | `interrupt(connection_hdl)` | 0.3.0 Core |
Interrupt events can be triggered by calling `endpoint::interrupt` or `connection::interrupt`.
Interrupt is similar to a timer event with duration zero but with lower overhead. It is useful
for single threaded programs to allow breaking up a very long handler into multiple parts and
for multi threaded programs as a way for worker threads to signale to the main/network thread
that an event is ready.
todo: write low and high watermark handlers
*/
+102
View File
@@ -0,0 +1,102 @@
/** \page reference.logging Logging Reference
WebSocket++ has the capability of logging events during the lifetime of the connections that it processes. Each endpoint has two independent logging interfaces that are used by all connections created by that endpoint. The first is an access interface that allows logging routine events in the life of a connection (such as connect/disconnect and receipt of messages). The other is an error interface that allows logging non-routine problems or errors. Each interface has a number of different named channels that can be toggled on and off independently.
Exactly how these logs are processed and where they are written to depends on which logging policy is in use. Several logging policies are included by default and you can write your own policy if you need something more specialized. Selecting a policy is done via the \subpage reference.config "endpoint config".
Common functionality (all policies)
-----------------------------------
### Logging Channels
Each logging interface is divided into 32 named channels. Log messages are written to a specific interface on a specific channel. Which log messages are actually printed is determined by which channels are enabled or not. Channels can be enabled or disabled either at compile time or at runtime.
### Enabling and Disabling Channels
Channels disabled at compile time are removed from the code entirely (assuming correct compiler optimization settings) and are not available for runtime enabling or disabling. To disable channels at compile time, use the `alog_level` and `elog_level` values within your \subpage reference.config "endpoint config". Channels not disabled at compile time can be enabled or disabled at runtime using the `websocketpp::endpoint::set_access_channels()`, `websocketpp::endpoint::clear_access_channels()`, `websocketpp::endpoint::set_error_channels()`, and `websocketpp::endpoint::clear_error_channels()` methods.
The set and clear functions act only on the channels specified. `set_access_channels(log::alevel::connect)` will enable logging of new connections. Following this with `set_access_channels(log::alevel::disconnect)` will enable logging of disconnections in addition to connections. Use `clear*` functions to disable a specific channel. Channels may be combined using bitwise operations to create aggregate packages of channels that may be set or cleared at once. Default packages include `websocketpp::log::alevel::all`, `websocketpp::log::elevel::all`, `websocketpp::log::alevel::none`, `websocketpp::log::elevel::none`. These represent all possible access/error channels and no access/error channels respectively. For convenience, setting none is aliased to clearing all.
### Examples
__Disable all__
`clear_access_channels(log::alevel::all)`
__Disable all (alternative method)__
`set_access_channels(log::alevel::none)`
__Multiple channels at once__
`log::alevel::message_payload | log::alevel::message_payload`
__All except one__
`log::alevel::all ^ log::alevel::message_payload`
__Default settings__
By default, only debug/development logging is disabled.
### Access to underlying loggers
Logging interfaces may be directly accessed via their associated endpoint or connection using get_alog() and get_elog(). This allows access to methods specific to the chosen logging policy.
Basic Logging (Default Policy)
------------------------------
The basic logging policy (`websocketpp::log::basic`) writes logs to a std::ostream. By default, access logs are written to stdout and error logs are written to stderr. Each logging interface may be optionally redirected to an arbitrary C++ stream (including file streams) using the `websocketpp::log::basic::set_ostream()` method.
Syslog Logging
--------------
The syslog logging policy (`websocketpp::log::syslog`) logs to POSIX syslog. It is included in the header `<websocketpp/logger/syslog.hpp>`. It requires a system with `<syslog.h>`.
Stub Logging
------------
The stub logging policy (`websocketpp::log::stub`) implements the logging policy interface but ignores all input and provides no output. It can be used to stub out the logging system in tests or to completely disable and remove nearly all logging related code.
The stub logger also provides documentation for the minimal required interface to build a custom logging policy.
Log level reference
-------------------
### Error Logging Levels
Each of these channels is in the namespace `websocketpp::log::elevel`
| Level | Description |
| ------- | -------------------------------------------------------------------------------------------------------------------------- |
| none | Special aggregate value representing "no levels" |
| devel | Low level debugging information (warning: very chatty). Requires debug or custom config. |
| library | Information about unusual system states or other minor internal library problems, less chatty than devel. |
| info | Information about minor configuration problems or additional information about other warnings. |
| warn | Information about important problems not severe enough to terminate connections. |
| rerror | Recoverable error. Recovery may mean cleanly closing the connection with an appropriate error code to the remote endpoint. |
| fatal | Unrecoverable error. This error will trigger immediate unclean termination of the connection or endpoint. |
| all | Special aggregate value representing "all levels" |
### Access Logging Levels
Each of these channels is in the namespace `websocketpp::log::alevel`
| Level | Description |
| --------------- | -------------------------------------------------------------------------------------------------- |
| none | Special aggregate value representing "no levels" |
| connect | One line for each new connection that includes a host of information including: the remote address, websocket version, requested resource, http code, remote user agent |
| disconnect | One line for each connection that is closed. Includes closing codes and reasons |
| control | One line per control message |
| frame_header | One line per frame, includes the full frame header |
| frame_payload | One line per frame, includes the full message payload (warning: lots of output for large messages) |
| message_header | Reserved |
| message_payload | Reserved |
| endpoint | Reserved |
| debug_handshake | Extra information about opening handshakes |
| debug_close | Extra information about closing handshakes |
| devel | Development messages (warning: very chatty). Requires debug or custom config. |
| app | Special channel for application specific logs. Not used by the library. |
| all | Special aggregate value representing "all levels" |
*/
+22
View File
@@ -0,0 +1,22 @@
.tabs, .tabs2, .tabs3, .navpath ul {
background-image: none;
background-color: #333;
border: none;
border-bottom: 1px solid #575757;
}
.tablist li, .navpath li {
background-image: none;
background-color: #333;
}
.tablist a, .navpath li.navelem a {
color: #ccc;
text-shadow: 0px 1px 1px black;
}
.tablist a:hover, .navpath li.navelem a:hover {
background-image: none;
background-color: #444;
color: #ccc;
}
+23
View File
@@ -0,0 +1,23 @@
/** \mainpage
WebSocket++ is a C++ library that can be used to implement WebSocket functionality. The goals of the project are to provide a WebSocket implementation that is portable, flexible, lightweight, low level, and high performance.
WebSocket++ does not intend to be used alone as a web application framework or full featured web services platform. As such the components, examples, and performance tuning are geared towards operation as a WebSocket client or server. There are some minimal convenience features that stray from this (for example the ability to respond to HTTP requests other than WebSocket Upgrades) but these are not the focus of the project. In particular WebSocket++ does not intend to implement any non-WebSocket related fallback options (ajax / long polling / comet / etc).
In order to remain compact and improve portability, the WebSocket++ project strives to reduce or eliminate external dependencies where possible and appropriate. WebSocket++ core has no dependencies other than the C++11 standard library. For non-C++11 compilers the Boost libraries provide drop in polyfills for the C++11 functionality used.
WebSocket++ implements a pluggable data transport component. The default component allows reduced functionality by using STL iostream or raw byte shuffling via reading and writing char buffers. This component has no non-STL dependencies and can be used in a C++11 environment without Boost. Also included is an Asio based transport component that provides full featured network client/server functionality. This component requires either Boost Asio or a C++11 compiler and standalone Asio. As an advanced option, WebSocket++ supports custom transport layers if you want to provide your own using another library.
In order to accommodate the wide variety of use cases WebSocket++ has collected, the library is built in a way that most of the major components are loosely coupled and can be swapped out and replaced. WebSocket++ will attempt to track the future development of the WebSocket protocol and any extensions as they are developed.
- \subpage getting_started "Getting Started"
- \subpage faq "FAQ"
- \subpage tutorials "Tutorials"
- \subpage md_changelog "Change Log / Version History"
- Reference
- \subpage reference.handlers "Handler Reference"
- \subpage reference.config "Config Reference"
- \subpage reference.logging "Logging Reference"
*/
+52
View File
@@ -0,0 +1,52 @@
#include <set>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
using websocketpp::connection_hdl;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
class broadcast_server {
public:
broadcast_server() {
m_server.init_asio();
m_server.set_open_handler(bind(&broadcast_server::on_open,this,::_1));
m_server.set_close_handler(bind(&broadcast_server::on_close,this,::_1));
m_server.set_message_handler(bind(&broadcast_server::on_message,this,::_1,::_2));
}
void on_open(connection_hdl hdl) {
m_connections.insert(hdl);
}
void on_close(connection_hdl hdl) {
m_connections.erase(hdl);
}
void on_message(connection_hdl hdl, server::message_ptr msg) {
for (auto it : m_connections) {
m_server.send(it,msg);
}
}
void run(uint16_t port) {
m_server.listen(port);
m_server.start_accept();
m_server.run();
}
private:
typedef std::set<connection_hdl,std::owner_less<connection_hdl>> con_list;
server m_server;
con_list m_connections;
};
int main() {
broadcast_server server;
server.run(9002);
}
+65
View File
@@ -0,0 +1,65 @@
#include <functional>
#include <mutex>
#include <set>
#include <thread>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
using websocketpp::connection_hdl;
class count_server {
public:
count_server() : m_count(0) {
m_server.init_asio();
m_server.set_open_handler(bind(&count_server::on_open,this,_1));
m_server.set_close_handler(bind(&count_server::on_close,this,_1));
}
void on_open(connection_hdl hdl) {
std::lock_guard<std::mutex> lock(m_mutex);
m_connections.insert(hdl);
}
void on_close(connection_hdl hdl) {
std::lock_guard<std::mutex> lock(m_mutex);
m_connections.erase(hdl);
}
void count() {
while (1) {
sleep(1);
m_count++;
std::stringstream ss;
ss << m_count;
std::lock_guard<std::mutex> lock(m_mutex);
for (auto it : m_connections) {
m_server.send(it,ss.str(),websocketpp::frame::opcode::text);
}
}
}
void run(uint16_t port) {
m_server.listen(port);
m_server.start_accept();
m_server.run();
}
private:
typedef std::set<connection_hdl,std::owner_less<connection_hdl>> con_list;
int m_count;
server m_server;
con_list m_connections;
std::mutex m_mutex;
};
int main() {
count_server server;
std::thread t(std::bind(&count_server::count,&server));
server.run(9002);
}
+10
View File
@@ -0,0 +1,10 @@
/** \page tutorials Tutorials
These tutorials are works in progress, some are more complete than others.
- \subpage md_tutorials_utility_client_utility_client
- \subpage md_tutorials_utility_server_utility_server
- \subpage md_tutorials_broadcast_tutorial_broadcast_tutorial
- \subpage md_tutorials_chat_tutorial_chat_tutorial
*/
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (associative_storage)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
@@ -0,0 +1,88 @@
#include <iostream>
#include <map>
#include <exception>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
using websocketpp::connection_hdl;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
struct connection_data {
int sessionid;
std::string name;
};
class print_server {
public:
print_server() : m_next_sessionid(1) {
m_server.init_asio();
m_server.set_open_handler(bind(&print_server::on_open,this,::_1));
m_server.set_close_handler(bind(&print_server::on_close,this,::_1));
m_server.set_message_handler(bind(&print_server::on_message,this,::_1,::_2));
}
void on_open(connection_hdl hdl) {
connection_data data;
data.sessionid = m_next_sessionid++;
data.name.clear();
m_connections[hdl] = data;
}
void on_close(connection_hdl hdl) {
connection_data& data = get_data_from_hdl(hdl);
std::cout << "Closing connection " << data.name
<< " with sessionid " << data.sessionid << std::endl;
m_connections.erase(hdl);
}
void on_message(connection_hdl hdl, server::message_ptr msg) {
connection_data& data = get_data_from_hdl(hdl);
if (data.name.empty()) {
data.name = msg->get_payload();
std::cout << "Setting name of connection with sessionid "
<< data.sessionid << " to " << data.name << std::endl;
} else {
std::cout << "Got a message from connection " << data.name
<< " with sessionid " << data.sessionid << std::endl;
}
}
connection_data& get_data_from_hdl(connection_hdl hdl) {
auto it = m_connections.find(hdl);
if (it == m_connections.end()) {
// this connection is not in the list. This really shouldn't happen
// and probably means something else is wrong.
throw std::invalid_argument("No data available for session");
}
return it->second;
}
void run(uint16_t port) {
m_server.listen(port);
m_server.start_accept();
m_server.run();
}
private:
typedef std::map<connection_hdl,connection_data,std::owner_less<connection_hdl>> con_list;
int m_next_sessionid;
server m_server;
con_list m_connections;
};
int main() {
print_server server;
server.run(9002);
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (broadcast_server)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+23
View File
@@ -0,0 +1,23 @@
## Broadcast Server example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('broadcast_server', ["broadcast_server.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system','thread'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('broadcast_server', ["broadcast_server.cpp"], LIBS = ALL_LIBS)
Return('prgs')
@@ -0,0 +1,160 @@
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
#include <set>
/*#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>*/
#include <websocketpp/common/thread.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
using websocketpp::connection_hdl;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
using websocketpp::lib::thread;
using websocketpp::lib::mutex;
using websocketpp::lib::lock_guard;
using websocketpp::lib::unique_lock;
using websocketpp::lib::condition_variable;
/* on_open insert connection_hdl into channel
* on_close remove connection_hdl from channel
* on_message queue send to all channels
*/
enum action_type {
SUBSCRIBE,
UNSUBSCRIBE,
MESSAGE
};
struct action {
action(action_type t, connection_hdl h) : type(t), hdl(h) {}
action(action_type t, connection_hdl h, server::message_ptr m)
: type(t), hdl(h), msg(m) {}
action_type type;
websocketpp::connection_hdl hdl;
server::message_ptr msg;
};
class broadcast_server {
public:
broadcast_server() {
// Initialize Asio Transport
m_server.init_asio();
// Register handler callbacks
m_server.set_open_handler(bind(&broadcast_server::on_open,this,::_1));
m_server.set_close_handler(bind(&broadcast_server::on_close,this,::_1));
m_server.set_message_handler(bind(&broadcast_server::on_message,this,::_1,::_2));
}
void run(uint16_t port) {
// listen on specified port
m_server.listen(port);
// Start the server accept loop
m_server.start_accept();
// Start the ASIO io_service run loop
try {
m_server.run();
} catch (const std::exception & e) {
std::cout << e.what() << std::endl;
}
}
void on_open(connection_hdl hdl) {
{
lock_guard<mutex> guard(m_action_lock);
//std::cout << "on_open" << std::endl;
m_actions.push(action(SUBSCRIBE,hdl));
}
m_action_cond.notify_one();
}
void on_close(connection_hdl hdl) {
{
lock_guard<mutex> guard(m_action_lock);
//std::cout << "on_close" << std::endl;
m_actions.push(action(UNSUBSCRIBE,hdl));
}
m_action_cond.notify_one();
}
void on_message(connection_hdl hdl, server::message_ptr msg) {
// queue message up for sending by processing thread
{
lock_guard<mutex> guard(m_action_lock);
//std::cout << "on_message" << std::endl;
m_actions.push(action(MESSAGE,hdl,msg));
}
m_action_cond.notify_one();
}
void process_messages() {
while(1) {
unique_lock<mutex> lock(m_action_lock);
while(m_actions.empty()) {
m_action_cond.wait(lock);
}
action a = m_actions.front();
m_actions.pop();
lock.unlock();
if (a.type == SUBSCRIBE) {
lock_guard<mutex> guard(m_connection_lock);
m_connections.insert(a.hdl);
} else if (a.type == UNSUBSCRIBE) {
lock_guard<mutex> guard(m_connection_lock);
m_connections.erase(a.hdl);
} else if (a.type == MESSAGE) {
lock_guard<mutex> guard(m_connection_lock);
con_list::iterator it;
for (it = m_connections.begin(); it != m_connections.end(); ++it) {
m_server.send(*it,a.msg);
}
} else {
// undefined.
}
}
}
private:
typedef std::set<connection_hdl,std::owner_less<connection_hdl> > con_list;
server m_server;
con_list m_connections;
std::queue<action> m_actions;
mutex m_action_lock;
mutex m_connection_lock;
condition_variable m_action_cond;
};
int main() {
try {
broadcast_server server_instance;
// Start a thread to run the processing loop
thread t(bind(&broadcast_server::process_messages,&server_instance));
// Run the asio loop with the main thread
server_instance.run(9002);
t.join();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
}
}
-23
View File
@@ -1,23 +0,0 @@
CFLAGS = -O2
LDFLAGS =
CXX ?= c++
SHARED ?= "1"
ifeq ($(SHARED), 1)
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_thread -lwebsocketpp
else
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_thread -lboost_date_time -lboost_regex -lboost_random ../../libwebsocketpp.a
endif
chat_client: chat_client.o chat_client_handler.o
$(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS)
%.o: %.cpp
$(CXX) -c $(CFLAGS) -o $@ $^
# cleanup by removing generated files
#
.PHONY: clean
clean:
rm -f *.o chat_client
-78
View File
@@ -1,78 +0,0 @@
/*
* Copyright (c) 2011, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "chat_client_handler.hpp"
#include "../../src/websocketpp.hpp"
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <iostream>
using boost::asio::ip::tcp;
using namespace websocketchat;
int main(int argc, char* argv[]) {
std::string uri;
if (argc != 2) {
std::cout << "Usage: `chat_client ws_uri`" << std::endl;
} else {
uri = argv[1];
}
chat_client_handler_ptr c(new chat_client_handler());
try {
boost::asio::io_service io_service;
websocketpp::client_ptr client(new websocketpp::client(io_service,c));
client->init();
client->set_header("User Agent","WebSocket++/2011-09-25");
client->add_subprotocol("com.zaphoyd.websocketpp.chat");
client->set_origin("http://zaphoyd.com");
client->connect(uri);
boost::thread t(boost::bind(&boost::asio::io_service::run, &io_service));
char line[512];
while (std::cin.getline(line, 512)) {
c->send(line);
}
t.join();
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
return 0;
}
-177
View File
@@ -1,177 +0,0 @@
<!doctype html>
<html>
<head>
<script type="text/javascript" src="jquery-1.6.3.min.js"></script>
</head>
<body>
<script type="text/javascript">
var ws;
var url;
$(document).ready(init);
function init() {
$(document).keypress(function(event) {
if ( event.which == 13 ) {
event.preventDefault();
send();
}
});
}
function connect() {
url = $("#server_url").val();
console.log(url);
if ("WebSocket" in window) {
ws = new WebSocket(url);
} else if ("MozWebSocket" in window) {
ws = new MozWebSocket(url);
} else {
chat_message("This Browser does not support WebSockets");
return;
}
ws.onopen = function(e) {
chat_message("A connection to "+url+" has been opened.");
$("#server_url").attr("disabled",true);
$("#toggle_connect").html("Disconnect");
};
ws.onerror = function(e) {
chat_message("An error occured, see console log for more details.");
console.log(e);
};
ws.onclose = function(e) {
chat_message("The connection to "+url+" was closed.");
};
ws.onmessage = function(e) {
var message = JSON.parse(e.data);
if (message.type == "msg") {
chat_message(message.value,message.sender);
} else if (message.type == "participants") {
var o = "<ul>";
for (var p in message.value) {
o += "<li>"+message.value[p]+"</li>";
}
o += "</ul>";
$("#participants").html(o);
}
};
}
function chat_message(message,sender) {
if (arguments.length == 1) {
sender = "";
}
var style;
if (sender == "") {
style = "client";
} else if (sender == "server") {
style = "server";
sender = "["+sender+"]";
} else {
style = "message";
sender = "["+sender+"]";
}
$("#messages").append("<span class='"+style+"'><span class='sender'>"+sender+"</span> <span class='msg'>"+message+"</span></span><br />");
$("#messages").prop({ scrollTop: $("#messages").prop("scrollHeight") });
}
function disconnect() {
ws.close();
$("#server_url").removeAttr("disabled");
$("#toggle_connect").html("Connect");
$("#participants").html("");
}
function toggle_connect() {
if ($("#server_url").attr("disabled") != "disabled") {
connect();
} else {
disconnect();
}
}
function send() {
if (ws === undefined || ws.readyState != 1) {
chat_message("Websocket is not avaliable for writing");
return;
}
ws.send($("#msg").val());
$("#msg").val("");
}
</script>
<style>
body,html {
margin: 0px;
padding: 0px;
height: 100%;
background-color: #999;
font-family: sans-serif;
font-size: 14px;
}
h3 {
}
#controls {
padding: 4px;
float:right;
width: 300px;
}
input {
width: 200px;
}
#messages {
height: 100%;
overflow: auto;
background-color: black;
}
#messages .client {
color: #ccc;
}
#messages .server {
color: yellow;
}
#messages .message {
color: white;
}
</style>
<div id="controls">
<div id="server">
<input type="text" name="server_url" id="server_url" value="ws://thor-websocket.zaphoyd.net:9000/chat" />
<button id="toggle_connect" onclick="toggle_connect();">Connect</button>
</div>
<div id="message_input"><input type="text" name="msg" id="msg" value="Hello World!" />
<button onclick="send();">Send</button></div>
<h3>Chat Participants</h3>
<div id="participants"></div>
</div>
<div id="messages"></div>
</body>
</html>
@@ -1,171 +0,0 @@
/*
* Copyright (c) 2011, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "chat_client_handler.hpp"
#include <boost/algorithm/string/replace.hpp>
using websocketchat::chat_client_handler;
using websocketpp::client_session_ptr;
void chat_client_handler::on_open(session_ptr s) {
// not sure if anything needs to happen here.
m_session = s;
std::cout << "Successfully connected" << std::endl;
}
void chat_client_handler::on_close(session_ptr s) {
// not sure if anything needs to happen here either.
m_session = client_session_ptr();
std::cout << "client was disconnected" << std::endl;
}
void chat_client_handler::on_message(session_ptr s,const std::string &msg) {
//std::cout << "message from server: " << msg << std::endl;
decode_server_msg(msg);
}
// CLIENT API
// client api methods will be called from outside the io_service.run thread
// they need to be careful to not touch unsyncronized member variables.
void chat_client_handler::send(const std::string &msg) {
if (!m_session) {
std::cerr << "Error: no connected session" << std::endl;
return;
}
m_session->io_service().post(boost::bind(&chat_client_handler::do_send, this, msg));
}
void chat_client_handler::close() {
if (!m_session) {
std::cerr << "Error: no connected session" << std::endl;
return;
}
m_session->io_service().post(boost::bind(&chat_client_handler::do_close,this));
}
// END CLIENT API
void chat_client_handler::do_send(const std::string &msg) {
if (!m_session) {
std::cerr << "Error: no connected session" << std::endl;
return;
}
// check for local commands
if (msg == "/list") {
std::cout << "list all participants" << std::endl;
} else if (msg == "/close") {
do_close();
} else {
m_session->send(msg);
}
}
void chat_client_handler::do_close() {
if (!m_session) {
std::cerr << "Error: no connected session" << std::endl;
return;
}
m_session->close(websocketpp::session::CLOSE_STATUS_GOING_AWAY,"");
}
// {"type":"participants","value":[<participant>,...]}
// {"type":"msg","sender":"<sender>","value":"<msg>" }
void chat_client_handler::decode_server_msg(const std::string &msg) {
// for messages of type participants, erase and rebuild m_participants
// for messages of type msg, print out message
// NOTE: The chat server was written with the intention of the client having a built in
// JSON parser. To keep external dependencies low for this demonstration chat client I am
// parsing the server messages by hand.
std::string::size_type start = 9;
std::string::size_type end;
if (msg.substr(0,start) != "{\"type\":\"") {
// ignore
std::cout << "invalid message" << std::endl;
return;
}
if (msg.substr(start,15) == "msg\",\"sender\":\"") {
// parse message
std::string sender;
std::string message;
start += 15;
end = msg.find("\"",start);
while (end != std::string::npos) {
if (msg[end-1] == '\\') {
sender += msg.substr(start,end-start-1) + "\"";
start = end+1;
end = msg.find("\"",start);
} else {
sender += msg.substr(start,end-start);
start = end;
break;
}
}
if (msg.substr(start,11) != "\",\"value\":\"") {
std::cout << "invalid message" << std::endl;
return;
}
start += 11;
end = msg.find("\"",start);
while (end != std::string::npos) {
if (msg[end-1] == '\\') {
message += msg.substr(start,end-start-1) + "\"";
start = end+1;
end = msg.find("\"",start);
} else {
message += msg.substr(start,end-start);
start = end;
break;
}
}
std::cout << "[" << sender << "] " << message << std::endl;
} else if (msg.substr(start,23) == "participants\",\"value\":[") {
// parse participants
std::cout << "participants message" << std::endl;
} else {
// unknown message type
std::cout << "unknown message" << std::endl;
}
}
@@ -1,94 +0,0 @@
/*
* Copyright (c) 2011, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef CHAT_CLIENT_HANDLER_HPP
#define CHAT_CLIENT_HANDLER_HPP
// com.zaphoyd.websocketpp.chat protocol
//
// client messages:
// alias [UTF8 text, 16 characters max]
// msg [UTF8 text]
//
// server messages:
// {"type":"msg","sender":"<sender>","value":"<msg>" }
// {"type":"participants","value":[<participant>,...]}
#include <boost/shared_ptr.hpp>
#include "../../src/websocketpp.hpp"
#include "../../src/websocket_connection_handler.hpp"
#include <map>
#include <string>
#include <queue>
using websocketpp::session_ptr;
namespace websocketchat {
class chat_client_handler : public websocketpp::connection_handler {
public:
chat_client_handler() {}
virtual ~chat_client_handler() {}
// ignored for clients?
void validate(session_ptr s) {}
// connection to chat room complete
void on_open(session_ptr s);
// connection to chat room closed
void on_close(session_ptr s);
// got a new message from server
void on_message(session_ptr s,const std::string &msg);
// ignore messages
void on_message(session_ptr s,const std::vector<unsigned char> &data) {}
// CLIENT API
void send(const std::string &msg);
void close();
private:
// Client API internal
void do_send(const std::string &msg);
void do_close();
void decode_server_msg(const std::string &msg);
// list of other chat participants
std::set<std::string> m_participants;
std::queue<std::string> m_msg_queue;
session_ptr m_session;
};
typedef boost::shared_ptr<chat_client_handler> chat_client_handler_ptr;
}
#endif // CHAT_CLIENT_HANDLER_HPP
File diff suppressed because one or more lines are too long
-23
View File
@@ -1,23 +0,0 @@
CFLAGS = -O2
LDFLAGS =
CXX ?= c++
SHARED ?= "1"
ifeq ($(SHARED), 1)
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_date_time -lwebsocketpp
else
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_date_time -lboost_regex -lboost_random -lboost_program_options ../../libwebsocketpp.a
endif
chat_server: chat_server.o chat.o
$(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS)
%.o: %.cpp
$(CXX) -c $(CFLAGS) -o $@ $^
# cleanup by removing generated files
#
.PHONY: clean
clean:
rm -f *.o chat_server
-192
View File
@@ -1,192 +0,0 @@
/*
* Copyright (c) 2011, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "chat.hpp"
#include <boost/algorithm/string/replace.hpp>
using websocketchat::chat_server_handler;
using websocketpp::session_ptr;
void chat_server_handler::validate(session_ptr client) {
std::stringstream err;
// We only know about the chat resource
if (client->get_resource() != "/chat") {
err << "Request for unknown resource " << client->get_resource();
throw(websocketpp::handshake_error(err.str(),404));
}
// Require specific origin example
if (client->get_origin() != "http://zaphoyd.com") {
err << "Request from unrecognized origin: " << client->get_origin();
throw(websocketpp::handshake_error(err.str(),403));
}
}
void chat_server_handler::on_open(session_ptr client) {
std::cout << "client " << client << " joined the lobby." << std::endl;
m_connections.insert(std::pair<session_ptr,std::string>(client,get_con_id(client)));
// send user list and signon message to all clients
send_to_all(serialize_state());
client->send(encode_message("server","Welcome, use the /alias command to set a name, /help for a list of other commands."));
send_to_all(encode_message("server",m_connections[client]+" has joined the chat."));
}
void chat_server_handler::on_close(session_ptr client) {
std::map<session_ptr,std::string>::iterator it = m_connections.find(client);
if (it == m_connections.end()) {
// this client has already disconnected, we can ignore this.
// this happens during certain types of disconnect where there is a
// deliberate "soft" disconnection preceeding the "hard" socket read
// fail or disconnect ack message.
return;
}
std::cout << "client " << client << " left the lobby." << std::endl;
const std::string alias = it->second;
m_connections.erase(it);
// send user list and signoff message to all clients
send_to_all(serialize_state());
send_to_all(encode_message("server",alias+" has left the chat."));
}
void chat_server_handler::on_message(session_ptr client,const std::string &msg) {
std::cout << "message from client " << client << ": " << msg << std::endl;
// check for special command messages
if (msg == "/help") {
// print command list
client->send(encode_message("server","avaliable commands:<br />&nbsp;&nbsp;&nbsp;&nbsp;/help - show this help<br />&nbsp;&nbsp;&nbsp;&nbsp;/alias foo - set alias to foo",false));
return;
}
if (msg.substr(0,7) == "/alias ") {
std::string response;
std::string alias;
if (msg.size() == 7) {
response = "You must enter an alias.";
client->send(encode_message("server",response));
return;
} else {
alias = msg.substr(7);
}
response = m_connections[client] + " is now known as "+alias;
// store alias pre-escaped so we don't have to do this replacing every time this
// user sends a message
// escape JSON characters
boost::algorithm::replace_all(alias,"\\","\\\\");
boost::algorithm::replace_all(alias,"\"","\\\"");
// escape HTML characters
boost::algorithm::replace_all(alias,"&","&amp;");
boost::algorithm::replace_all(alias,"<","&lt;");
boost::algorithm::replace_all(alias,">","&gt;");
m_connections[client] = alias;
// set alias
send_to_all(serialize_state());
send_to_all(encode_message("server",response));
return;
}
// catch other slash commands
if (msg[0] == '/') {
client->send(encode_message("server","unrecognized command"));
return;
}
// create JSON message to send based on msg
send_to_all(encode_message(m_connections[client],msg));
}
// {"type":"participants","value":[<participant>,...]}
std::string chat_server_handler::serialize_state() {
std::stringstream s;
s << "{\"type\":\"participants\",\"value\":[";
std::map<session_ptr,std::string>::iterator it;
for (it = m_connections.begin(); it != m_connections.end(); it++) {
s << "\"" << (*it).second << "\"";
if (++it != m_connections.end()) {
s << ",";
}
it--;
}
s << "]}";
return s.str();
}
// {"type":"msg","sender":"<sender>","value":"<msg>" }
std::string chat_server_handler::encode_message(std::string sender,std::string msg,bool escape) {
std::stringstream s;
// escape JSON characters
boost::algorithm::replace_all(msg,"\\","\\\\");
boost::algorithm::replace_all(msg,"\"","\\\"");
// escape HTML characters
if (escape) {
boost::algorithm::replace_all(msg,"&","&amp;");
boost::algorithm::replace_all(msg,"<","&lt;");
boost::algorithm::replace_all(msg,">","&gt;");
}
s << "{\"type\":\"msg\",\"sender\":\"" << sender
<< "\",\"value\":\"" << msg << "\"}";
return s.str();
}
std::string chat_server_handler::get_con_id(session_ptr s) {
std::stringstream endpoint;
endpoint << s->socket().remote_endpoint();
return endpoint.str();
}
void chat_server_handler::send_to_all(std::string data) {
std::map<session_ptr,std::string>::iterator it;
for (it = m_connections.begin(); it != m_connections.end(); it++) {
(*it).first->send(data);
}
}
-83
View File
@@ -1,83 +0,0 @@
/*
* Copyright (c) 2011, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef CHAT_HPP
#define CHAT_HPP
// com.zaphoyd.websocketpp.chat protocol
//
// client messages:
// alias [UTF8 text, 16 characters max]
// msg [UTF8 text]
//
// server messages:
// {"type":"msg","sender":"<sender>","value":"<msg>" }
// {"type":"participants","value":[<participant>,...]}
#include <boost/shared_ptr.hpp>
#include "../../src/websocketpp.hpp"
#include "../../src/websocket_connection_handler.hpp"
#include <map>
#include <string>
#include <vector>
namespace websocketchat {
class chat_server_handler : public websocketpp::connection_handler {
public:
chat_server_handler() {}
virtual ~chat_server_handler() {}
void validate(websocketpp::session_ptr client);
// add new connection to the lobby
void on_open(websocketpp::session_ptr client);
// someone disconnected from the lobby, remove them
void on_close(websocketpp::session_ptr client);
void on_message(websocketpp::session_ptr client,const std::string &msg);
// lobby will ignore binary messages
void on_message(websocketpp::session_ptr client,
const std::vector<unsigned char> &data) {}
private:
std::string serialize_state();
std::string encode_message(std::string sender,std::string msg,bool escape = true);
std::string get_con_id(websocketpp::session_ptr s);
void send_to_all(std::string data);
// list of outstanding connections
std::map<websocketpp::session_ptr,std::string> m_connections;
};
typedef boost::shared_ptr<chat_server_handler> chat_server_handler_ptr;
}
#endif // CHAT_HPP
-177
View File
@@ -1,177 +0,0 @@
<!doctype html>
<html>
<head>
<script type="text/javascript" src="jquery-1.6.3.min.js"></script>
</head>
<body>
<script type="text/javascript">
var ws;
var url;
$(document).ready(init);
function init() {
$(document).keypress(function(event) {
if ( event.which == 13 ) {
event.preventDefault();
send();
}
});
}
function connect() {
url = $("#server_url").val();
console.log(url);
if ("WebSocket" in window) {
ws = new WebSocket(url);
} else if ("MozWebSocket" in window) {
ws = new MozWebSocket(url);
} else {
chat_message("This Browser does not support WebSockets");
return;
}
ws.onopen = function(e) {
chat_message("A connection to "+url+" has been opened.");
$("#server_url").attr("disabled",true);
$("#toggle_connect").html("Disconnect");
};
ws.onerror = function(e) {
chat_message("An error occured, see console log for more details.");
console.log(e);
};
ws.onclose = function(e) {
chat_message("The connection to "+url+" was closed.");
};
ws.onmessage = function(e) {
var message = JSON.parse(e.data);
if (message.type == "msg") {
chat_message(message.value,message.sender);
} else if (message.type == "participants") {
var o = "<ul>";
for (var p in message.value) {
o += "<li>"+message.value[p]+"</li>";
}
o += "</ul>";
$("#participants").html(o);
}
};
}
function chat_message(message,sender) {
if (arguments.length == 1) {
sender = "";
}
var style;
if (sender == "") {
style = "client";
} else if (sender == "server") {
style = "server";
sender = "["+sender+"]";
} else {
style = "message";
sender = "["+sender+"]";
}
$("#messages").append("<span class='"+style+"'><span class='sender'>"+sender+"</span> <span class='msg'>"+message+"</span></span><br />");
$("#messages").prop({ scrollTop: $("#messages").prop("scrollHeight") });
}
function disconnect() {
ws.close();
$("#server_url").removeAttr("disabled");
$("#toggle_connect").html("Connect");
$("#participants").html("");
}
function toggle_connect() {
if ($("#server_url").attr("disabled") != "disabled") {
connect();
} else {
disconnect();
}
}
function send() {
if (ws === undefined || ws.readyState != 1) {
chat_message("Websocket is not avaliable for writing");
return;
}
ws.send($("#msg").val());
$("#msg").val("");
}
</script>
<style>
body,html {
margin: 0px;
padding: 0px;
height: 100%;
background-color: #999;
font-family: sans-serif;
font-size: 14px;
}
h3 {
}
#controls {
padding: 4px;
float:right;
width: 300px;
}
input {
width: 200px;
}
#messages {
height: 100%;
overflow: auto;
background-color: black;
}
#messages .client {
color: #ccc;
}
#messages .server {
color: yellow;
}
#messages .message {
color: white;
}
</style>
<div id="controls">
<div id="server">
<input type="text" name="server_url" id="server_url" value="ws://thor-websocket.zaphoyd.net:9000/chat" />
<button id="toggle_connect" onclick="toggle_connect();">Connect</button>
</div>
<div id="message_input"><input type="text" name="msg" id="msg" value="Hello World!" />
<button onclick="send();">Send</button></div>
<h3>Chat Participants</h3>
<div id="participants"></div>
</div>
<div id="messages"></div>
</body>
</html>
-84
View File
@@ -1,84 +0,0 @@
/*
* Copyright (c) 2011, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "chat.hpp"
#include "../../src/websocketpp.hpp"
#include <boost/asio.hpp>
#include <iostream>
using boost::asio::ip::tcp;
using namespace websocketchat;
int main(int argc, char* argv[]) {
std::string host = "localhost";
short port = 9003;
std::string full_host;
if (argc == 3) {
// TODO: input validation?
host = argv[1];
port = atoi(argv[2]);
}
std::stringstream temp;
temp << host << ":" << port;
full_host = temp.str();
chat_server_handler_ptr chat_handler(new chat_server_handler());
try {
boost::asio::io_service io_service;
tcp::endpoint endpoint(tcp::v6(), port);
websocketpp::server_ptr server(
new websocketpp::server(io_service,endpoint,chat_handler)
);
// setup server settings
server->add_host(host);
server->add_host(full_host);
// Chat server should only be receiving small text messages, reduce max
// message size limit slightly to save memory, improve performance, and
// guard against DoS attacks.
server->set_max_message_size(0xFFFF); // 64KiB
// start the server
server->start_accept();
std::cout << "Starting chat server on " << full_host << std::endl;
io_service.run();
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
return 0;
}
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
if (OPENSSL_FOUND)
init_target (debug_client)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
link_openssl()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
endif()
+24
View File
@@ -0,0 +1,24 @@
## Debug client example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
Import('tls_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env_cpp11.Program('debug_client', ["debug_client.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system','random'],env) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env.Program('debug_client', ["debug_client.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+167
View File
@@ -0,0 +1,167 @@
/*
* Copyright (c) 2014, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** ====== WARNING ========
* This example is presently used as a scratch space. It may or may not be broken
* at any given time.
*/
#include <websocketpp/config/asio_client.hpp>
#include <websocketpp/client.hpp>
#include <iostream>
#include <chrono>
typedef websocketpp::client<websocketpp::config::asio_client> client;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef websocketpp::config::asio_tls_client::message_type::ptr message_ptr;
typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr;
typedef client::connection_ptr connection_ptr;
class perftest {
public:
typedef perftest type;
typedef std::chrono::duration<int,std::micro> dur_type;
perftest () {
m_endpoint.set_access_channels(websocketpp::log::alevel::all);
m_endpoint.set_error_channels(websocketpp::log::elevel::all);
// Initialize ASIO
m_endpoint.init_asio();
// Register our handlers
m_endpoint.set_socket_init_handler(bind(&type::on_socket_init,this,::_1));
//m_endpoint.set_tls_init_handler(bind(&type::on_tls_init,this,::_1));
m_endpoint.set_message_handler(bind(&type::on_message,this,::_1,::_2));
m_endpoint.set_open_handler(bind(&type::on_open,this,::_1));
m_endpoint.set_close_handler(bind(&type::on_close,this,::_1));
m_endpoint.set_fail_handler(bind(&type::on_fail,this,::_1));
}
void start(std::string uri) {
websocketpp::lib::error_code ec;
client::connection_ptr con = m_endpoint.get_connection(uri, ec);
if (ec) {
m_endpoint.get_alog().write(websocketpp::log::alevel::app,ec.message());
return;
}
//con->set_proxy("http://humupdates.uchicago.edu:8443");
m_endpoint.connect(con);
// Start the ASIO io_service run loop
m_start = std::chrono::high_resolution_clock::now();
m_endpoint.run();
}
void on_socket_init(websocketpp::connection_hdl) {
m_socket_init = std::chrono::high_resolution_clock::now();
}
context_ptr on_tls_init(websocketpp::connection_hdl) {
m_tls_init = std::chrono::high_resolution_clock::now();
context_ptr ctx = websocketpp::lib::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::tlsv1);
try {
ctx->set_options(boost::asio::ssl::context::default_workarounds |
boost::asio::ssl::context::no_sslv2 |
boost::asio::ssl::context::no_sslv3 |
boost::asio::ssl::context::single_dh_use);
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
}
return ctx;
}
void on_fail(websocketpp::connection_hdl hdl) {
client::connection_ptr con = m_endpoint.get_con_from_hdl(hdl);
std::cout << "Fail handler" << std::endl;
std::cout << con->get_state() << std::endl;
std::cout << con->get_local_close_code() << std::endl;
std::cout << con->get_local_close_reason() << std::endl;
std::cout << con->get_remote_close_code() << std::endl;
std::cout << con->get_remote_close_reason() << std::endl;
std::cout << con->get_ec() << " - " << con->get_ec().message() << std::endl;
}
void on_open(websocketpp::connection_hdl hdl) {
m_open = std::chrono::high_resolution_clock::now();
m_endpoint.send(hdl, "", websocketpp::frame::opcode::text);
}
void on_message(websocketpp::connection_hdl hdl, message_ptr) {
m_message = std::chrono::high_resolution_clock::now();
m_endpoint.close(hdl,websocketpp::close::status::going_away,"");
}
void on_close(websocketpp::connection_hdl) {
m_close = std::chrono::high_resolution_clock::now();
std::cout << "Socket Init: " << std::chrono::duration_cast<dur_type>(m_socket_init-m_start).count() << std::endl;
std::cout << "TLS Init: " << std::chrono::duration_cast<dur_type>(m_tls_init-m_start).count() << std::endl;
std::cout << "Open: " << std::chrono::duration_cast<dur_type>(m_open-m_start).count() << std::endl;
std::cout << "Message: " << std::chrono::duration_cast<dur_type>(m_message-m_start).count() << std::endl;
std::cout << "Close: " << std::chrono::duration_cast<dur_type>(m_close-m_start).count() << std::endl;
}
private:
client m_endpoint;
std::chrono::high_resolution_clock::time_point m_start;
std::chrono::high_resolution_clock::time_point m_socket_init;
std::chrono::high_resolution_clock::time_point m_tls_init;
std::chrono::high_resolution_clock::time_point m_open;
std::chrono::high_resolution_clock::time_point m_message;
std::chrono::high_resolution_clock::time_point m_close;
};
int main(int argc, char* argv[]) {
std::string uri = "wss://echo.websocket.org";
if (argc == 2) {
uri = argv[1];
}
try {
perftest endpoint;
endpoint.start(uri);
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
} catch (std::exception const & e) {
std::cout << e.what() << std::endl;
} catch (...) {
std::cout << "other exception" << std::endl;
}
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (debug_server)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+23
View File
@@ -0,0 +1,23 @@
## Debug server example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('debug_server', ["debug_server.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('debug_server', ["debug_server.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+174
View File
@@ -0,0 +1,174 @@
/*
* Copyright (c) 2014, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** ====== WARNING ========
* This example is presently used as a scratch space. It may or may not be broken
* at any given time.
*/
#include <websocketpp/config/debug_asio_no_tls.hpp>
// Custom logger
#include <websocketpp/logger/syslog.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
////////////////////////////////////////////////////////////////////////////////
///////////////// Custom Config for debugging custom policies //////////////////
////////////////////////////////////////////////////////////////////////////////
struct debug_custom : public websocketpp::config::debug_asio {
typedef debug_custom type;
typedef debug_asio base;
typedef base::concurrency_type concurrency_type;
typedef base::request_type request_type;
typedef base::response_type response_type;
typedef base::message_type message_type;
typedef base::con_msg_manager_type con_msg_manager_type;
typedef base::endpoint_msg_manager_type endpoint_msg_manager_type;
/// Custom Logging policies
/*typedef websocketpp::log::syslog<concurrency_type,
websocketpp::log::elevel> elog_type;
typedef websocketpp::log::syslog<concurrency_type,
websocketpp::log::alevel> alog_type;
*/
typedef base::alog_type alog_type;
typedef base::elog_type elog_type;
typedef base::rng_type rng_type;
struct transport_config : public base::transport_config {
typedef type::concurrency_type concurrency_type;
typedef type::alog_type alog_type;
typedef type::elog_type elog_type;
typedef type::request_type request_type;
typedef type::response_type response_type;
typedef websocketpp::transport::asio::basic_socket::endpoint
socket_type;
};
typedef websocketpp::transport::asio::endpoint<transport_config>
transport_type;
static const long timeout_open_handshake = 0;
};
////////////////////////////////////////////////////////////////////////////////
typedef websocketpp::server<debug_custom> server;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef server::message_ptr message_ptr;
bool validate(server *, websocketpp::connection_hdl) {
//sleep(6);
return true;
}
void on_http(server* s, websocketpp::connection_hdl hdl) {
server::connection_ptr con = s->get_con_from_hdl(hdl);
std::string res = con->get_request_body();
std::stringstream ss;
ss << "got HTTP request with " << res.size() << " bytes of body data.";
con->set_body(ss.str());
con->set_status(websocketpp::http::status_code::ok);
}
void on_fail(server* s, websocketpp::connection_hdl hdl) {
server::connection_ptr con = s->get_con_from_hdl(hdl);
std::cout << "Fail handler: " << con->get_ec() << " " << con->get_ec().message() << std::endl;
}
void on_close(websocketpp::connection_hdl) {
std::cout << "Close handler" << std::endl;
}
// Define a callback to handle incoming messages
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
std::cout << "on_message called with hdl: " << hdl.lock().get()
<< " and message: " << msg->get_payload()
<< std::endl;
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (websocketpp::exception const & e) {
std::cout << "Echo failed because: "
<< "(" << e.what() << ")" << std::endl;
}
}
int main() {
// Create a server endpoint
server echo_server;
try {
// Set logging settings
echo_server.set_access_channels(websocketpp::log::alevel::all);
echo_server.clear_access_channels(websocketpp::log::alevel::frame_payload);
// Initialize ASIO
echo_server.init_asio();
echo_server.set_reuse_addr(true);
// Register our message handler
echo_server.set_message_handler(bind(&on_message,&echo_server,::_1,::_2));
echo_server.set_http_handler(bind(&on_http,&echo_server,::_1));
echo_server.set_fail_handler(bind(&on_fail,&echo_server,::_1));
echo_server.set_close_handler(&on_close);
echo_server.set_validate_handler(bind(&validate,&echo_server,::_1));
// Listen on port 9012
echo_server.listen(9012);
// Start the server accept loop
echo_server.start_accept();
// Start the ASIO io_service run loop
echo_server.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
} catch (const std::exception & e) {
std::cout << e.what() << std::endl;
} catch (...) {
std::cout << "other exception" << std::endl;
}
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
#init_target (dev)
#build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
#link_boost ()
#final_target ()
#set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+18
View File
@@ -0,0 +1,18 @@
## Main development example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env_cpp11 = env_cpp11.Clone ()
prgs = []
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
BOOST_LIBS_CPP11 = boostlibs(['unit_test_framework','system','timer','chrono'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('main', ["main.cpp"], LIBS = BOOST_LIBS_CPP11)
Return('prgs')
+200
View File
@@ -0,0 +1,200 @@
//#ifndef _WEBSOCKETPP_CPP11_STL_
// #define _WEBSOCKETPP_CPP11_STL_
//#endif
#include <random>
#include <boost/timer/timer.hpp>
#include <websocketpp/config/core.hpp>
//#include <websocketpp/security/none.hpp>
//#include <websocketpp/concurrency/none.hpp>
//#include <websocketpp/concurrency/stl.hpp>
//#include <websocketpp/transport/iostream.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
#include <sstream>
//typedef websocketpp::concurrency::stl concurrency;
//typedef websocketpp::transport::iostream<concurrency> transport;
//typedef websocketpp::server<concurrency,transport> server;
typedef websocketpp::server<websocketpp::config::core> server;
/*class handler : public server::handler {
bool validate(connection_ptr con) {
std::cout << "handler validate" << std::endl;
if (con->get_origin() != "http://www.example.com") {
con->set_status(websocketpp::http::status_code::FORBIDDEN);
return false;
}
return true;
}
void http(connection_ptr con) {
std::cout << "handler http" << std::endl;
}
void on_load(connection_ptr con, ptr old_handler) {
std::cout << "handler on_load" << std::endl;
}
void on_unload(connection_ptr con, ptr new_handler) {
std::cout << "handler on_unload" << std::endl;
}
void on_open(connection_ptr con) {
std::cout << "handler on_open" << std::endl;
}
void on_fail(connection_ptr con) {
std::cout << "handler on_fail" << std::endl;
}
void on_message(connection_ptr con, message_ptr msg) {
std::cout << "handler on_message" << std::endl;
}
void on_close(connection_ptr con) {
std::cout << "handler on_close" << std::endl;
}
};*/
int main() {
typedef websocketpp::message_buffer::message<websocketpp::message_buffer::alloc::con_msg_manager>
message_type;
typedef websocketpp::message_buffer::alloc::con_msg_manager<message_type>
con_msg_man_type;
con_msg_man_type::ptr manager = websocketpp::lib::make_shared<con_msg_man_type>();
size_t foo = 1024;
message_type::ptr input = manager->get_message(websocketpp::frame::opcode::TEXT,foo);
message_type::ptr output = manager->get_message(websocketpp::frame::opcode::TEXT,foo);
websocketpp::frame::masking_key_type key;
std::random_device dev;
key.i = 0x12345678;
double m = 18094238402394.0824923;
/*std::cout << "Some Math" << std::endl;
{
boost::timer::auto_cpu_timer t;
for (int i = 0; i < foo; i++) {
m /= 1.001;
}
}*/
std::cout << m << std::endl;
std::cout << "Random Gen" << std::endl;
{
boost::timer::auto_cpu_timer t;
input->get_raw_payload().replace(0,foo,foo,'\0');
output->get_raw_payload().replace(0,foo,foo,'\0');
}
std::cout << "Out of place accelerated" << std::endl;
{
boost::timer::auto_cpu_timer t;
websocketpp::frame::word_mask_exact(reinterpret_cast<uint8_t*>(const_cast<char*>(input->get_raw_payload().data())), reinterpret_cast<uint8_t*>(const_cast<char*>(output->get_raw_payload().data())), foo, key);
}
std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
input->get_raw_payload().replace(0,foo,foo,'\0');
output->get_raw_payload().replace(0,foo,foo,'\0');
std::cout << "In place accelerated" << std::endl;
{
boost::timer::auto_cpu_timer t;
websocketpp::frame::word_mask_exact(reinterpret_cast<uint8_t*>(const_cast<char*>(input->get_raw_payload().data())), reinterpret_cast<uint8_t*>(const_cast<char*>(input->get_raw_payload().data())), foo, key);
}
std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
input->get_raw_payload().replace(0,foo,foo,'\0');
output->get_raw_payload().replace(0,foo,foo,'\0');
std::cout << "Out of place byte by byte" << std::endl;
{
boost::timer::auto_cpu_timer t;
websocketpp::frame::byte_mask(input->get_raw_payload().begin(), input->get_raw_payload().end(), output->get_raw_payload().begin(), key);
}
std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
input->get_raw_payload().replace(0,foo,foo,'\0');
output->get_raw_payload().replace(0,foo,foo,'\0');
std::cout << "In place byte by byte" << std::endl;
{
boost::timer::auto_cpu_timer t;
websocketpp::frame::byte_mask(input->get_raw_payload().begin(), input->get_raw_payload().end(), input->get_raw_payload().begin(), key);
}
std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
input->get_raw_payload().replace(0,foo,foo,'a');
output->get_raw_payload().replace(0,foo,foo,'b');
std::cout << "Copy" << std::endl;
{
boost::timer::auto_cpu_timer t;
std::copy(input->get_raw_payload().begin(), input->get_raw_payload().end(), output->get_raw_payload().begin());
}
std::cout << websocketpp::utility::to_hex(input->get_payload().c_str(),20) << std::endl;
std::cout << websocketpp::utility::to_hex(output->get_payload().c_str(),20) << std::endl;
/*server::handler::ptr h(new handler());
server test_server(h);
server::connection_ptr con;
std::stringstream output;
test_server.register_ostream(&output);
con = test_server.get_connection();
con->start();
//foo.handle_accept(con,true);
std::stringstream input;
input << "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\nOrigin: http://www.example.com\r\n\r\n";
//input << "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n";
input >> *con;
std::stringstream input2;
input2 << "messageabc2";
input2 >> *con;
std::stringstream input3;
input3 << "messageabc3";
input3 >> *con;
std::stringstream input4;
input4 << "close";
input4 >> *con;
std::cout << "connection output:" << std::endl;
std::cout << output.str() << std::endl;*/
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (echo_client)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
-23
View File
@@ -1,23 +0,0 @@
CFLAGS = -O2
LDFLAGS =
CXX ?= c++
SHARED ?= "1"
ifeq ($(SHARED), 1)
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_thread -lwebsocketpp
else
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_thread -lboost_date_time -lboost_regex -lboost_random -lboost_program_options ../../libwebsocketpp.a
endif
echo_client: echo_client.o echo_client_handler.o
$(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS)
%.o: %.cpp
$(CXX) -c $(CFLAGS) -o $@ $^
# cleanup by removing generated files
#
.PHONY: clean
clean:
rm -f *.o echo_client
+23
View File
@@ -0,0 +1,23 @@
## echo_client example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs] + ['z']
prgs += env_cpp11.Program('echo_client', ["echo_client.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system','random'],env) + [platform_libs] + [polyfill_libs] + ['z']
prgs += env.Program('echo_client', ["echo_client.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+70 -63
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Peter Thorson. All rights reserved.
* Copyright (c) 2016, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -11,10 +11,10 @@
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
@@ -22,69 +22,76 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#include "echo_client_handler.hpp"
#include "../../src/websocketpp.hpp"
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
#include <iostream>
using boost::asio::ip::tcp;
using namespace websocketecho;
typedef websocketpp::client<websocketpp::config::asio_client> client;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef websocketpp::config::asio_client::message_type::ptr message_ptr;
// This message handler will be invoked once for each incoming message. It
// prints the message and then sends a copy of the message back to the server.
void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) {
std::cout << "on_message called with hdl: " << hdl.lock().get()
<< " and message: " << msg->get_payload()
<< std::endl;
websocketpp::lib::error_code ec;
c->send(hdl, msg->get_payload(), msg->get_opcode(), ec);
if (ec) {
std::cout << "Echo failed because: " << ec.message() << std::endl;
}
}
int main(int argc, char* argv[]) {
std::string uri;
/*if (argc != 2) {
std::cout << "Usage: `echo_client test_url`" << std::endl;
} else {
uri = argv[1];
}*/
echo_client_handler_ptr c(new echo_client_handler());
try {
boost::asio::io_service io_service;
websocketpp::client_ptr client(new websocketpp::client(io_service,c));
client->init();
client->set_header("User Agent","WebSocket++/2011-10-27");
client->connect("ws://localhost:9001/getCaseCount");
io_service.run();
std::cout << "case count: " << c->m_case_count << std::endl;
for (int i = 1; i <= c->m_case_count; i++) {
io_service.reset();
client->set_alog_level(websocketpp::ALOG_OFF);
client->set_elog_level(websocketpp::LOG_OFF);
client->init();
client->set_header("User Agent","WebSocket++/2011-10-27");
std::stringstream url;
url << "ws://localhost:9001/runCase?case=" << i << "&agent=\"WebSocket++Snapshot/2011-10-27\"";
client->connect(url.str());
io_service.run();
}
std::cout << "done" << std::endl;
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
return 0;
// Create a client endpoint
client c;
std::string uri = "ws://localhost:9002";
if (argc == 2) {
uri = argv[1];
}
try {
// Set logging to be pretty verbose (everything except message payloads)
c.set_access_channels(websocketpp::log::alevel::all);
c.clear_access_channels(websocketpp::log::alevel::frame_payload);
// Initialize ASIO
c.init_asio();
// Register our message handler
c.set_message_handler(bind(&on_message,&c,::_1,::_2));
websocketpp::lib::error_code ec;
client::connection_ptr con = c.get_connection(uri, ec);
if (ec) {
std::cout << "could not create connection because: " << ec.message() << std::endl;
return 0;
}
// Note that connect here only requests a connection. No network messages are
// exchanged until the event loop starts running in the next line.
c.connect(con);
// Start the ASIO io_service run loop
// this will cause a single connection to be made to the server. c.run()
// will exit when this connection is closed.
c.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
}
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (echo_server)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
-23
View File
@@ -1,23 +0,0 @@
CFLAGS = -O2
LDFLAGS =
CXX ?= c++
SHARED ?= "1"
ifeq ($(SHARED), 1)
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_date_time -lwebsocketpp
else
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_date_time -lboost_regex -lboost_random -lboost_program_options ../../libwebsocketpp.a
endif
echo_server: echo_server.o echo.o
$(CXX) $(CFLAGS) $^ -o $@ $(LDFLAGS)
%.o: %.cpp
$(CXX) -c $(CFLAGS) -o $@ $^
# cleanup by removing generated files
#
.PHONY: clean
clean:
rm -f *.o echo_server
+23
View File
@@ -0,0 +1,23 @@
## Main development example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('echo_server', ["echo_server.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('echo_server', ["echo_server.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+37
View File
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2012, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef WEBSOCKETPP_ECHO_SERVER_HANDLER_HPP
#define WEBSOCKETPP_ECHO_SERVER_HANDLER_HPP
class echo_handler : public server::handler {
void on_message(connection_ptr con, std::string msg) {
con->write(msg);
}
};
#endif // WEBSOCKETPP_ECHO_SERVER_HANDLER_HPP
+59 -84
View File
@@ -1,90 +1,65 @@
/*
* Copyright (c) 2011, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <websocketpp/config/asio_no_tls.hpp>
#include "echo.hpp"
#include "../../src/websocketpp.hpp"
#include <boost/asio.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
using boost::asio::ip::tcp;
typedef websocketpp::server<websocketpp::config::asio> server;
int main(int argc, char* argv[]) {
std::string host = "localhost";
short port = 9002;
std::string full_host;
if (argc == 3) {
// TODO: input validation?
host = argv[1];
port = atoi(argv[2]);
}
std::stringstream temp;
temp << host << ":" << port;
full_host = temp.str();
websocketecho::echo_server_handler_ptr echo_handler(new websocketecho::echo_server_handler());
try {
boost::asio::io_service io_service;
tcp::endpoint endpoint(tcp::v6(), port);
websocketpp::server_ptr server(
new websocketpp::server(io_service,endpoint,echo_handler)
);
//server->parse_command_line(argc, argv);
// setup server settings
//server->set_alog_level(websocketpp::ALOG_OFF);
//server->set_elog_level(websocketpp::LOG_OFF);
server->add_host(host);
server->add_host(full_host);
// bump up max message size to maximum since we may be using the echo
// server to test performance and protocol extremes.
server->set_max_message_size(websocketpp::frame::PAYLOAD_64BIT_LIMIT);
// start the server
server->start_accept();
std::cout << "Starting echo server on " << full_host << std::endl;
// start asio
io_service.run();
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
return 0;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef server::message_ptr message_ptr;
// Define a callback to handle incoming messages
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
std::cout << "on_message called with hdl: " << hdl.lock().get()
<< " and message: " << msg->get_payload()
<< std::endl;
// check for a special command to instruct the server to stop listening so
// it can be cleanly exited.
if (msg->get_payload() == "stop-listening") {
s->stop_listening();
return;
}
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (websocketpp::exception const & e) {
std::cout << "Echo failed because: "
<< "(" << e.what() << ")" << std::endl;
}
}
int main() {
// Create a server endpoint
server echo_server;
try {
// Set logging settings
echo_server.set_access_channels(websocketpp::log::alevel::all);
echo_server.clear_access_channels(websocketpp::log::alevel::frame_payload);
// Initialize Asio
echo_server.init_asio();
// Register our message handler
echo_server.set_message_handler(bind(&on_message,&echo_server,::_1,::_2));
// Listen on port 9002
echo_server.listen(9002);
// Start the server accept loop
echo_server.start_accept();
// Start the ASIO io_service run loop
echo_server.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
} catch (...) {
std::cout << "other exception" << std::endl;
}
}
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
if (OPENSSL_FOUND)
init_target (echo_server_both)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
link_openssl()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
endif()
+24
View File
@@ -0,0 +1,24 @@
## Combo plain+tls echo server
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
Import('tls_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env_cpp11.Program('echo_server_both', ["echo_server_both.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env.Program('echo_server_both', ["echo_server_both.cpp"], LIBS = ALL_LIBS)
Return('prgs')
@@ -0,0 +1,87 @@
#include <websocketpp/config/asio.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
// define types for two different server endpoints, one for each config we are
// using
typedef websocketpp::server<websocketpp::config::asio> server_plain;
typedef websocketpp::server<websocketpp::config::asio_tls> server_tls;
// alias some of the bind related functions as they are a bit long
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// type of the ssl context pointer is long so alias it
typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr;
// The shared on_message handler takes a template parameter so the function can
// resolve any endpoint dependent types like message_ptr or connection_ptr
template <typename EndpointType>
void on_message(EndpointType* s, websocketpp::connection_hdl hdl,
typename EndpointType::message_ptr msg)
{
std::cout << "on_message called with hdl: " << hdl.lock().get()
<< " and message: " << msg->get_payload()
<< std::endl;
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (websocketpp::exception const & e) {
std::cout << "Echo failed because: "
<< "(" << e.what() << ")" << std::endl;
}
}
// No change to TLS init methods from echo_server_tls
std::string get_password() {
return "test";
}
context_ptr on_tls_init(websocketpp::connection_hdl hdl) {
std::cout << "on_tls_init called with hdl: " << hdl.lock().get() << std::endl;
context_ptr ctx(new boost::asio::ssl::context(boost::asio::ssl::context::tlsv1));
try {
ctx->set_options(boost::asio::ssl::context::default_workarounds |
boost::asio::ssl::context::no_sslv2 |
boost::asio::ssl::context::no_sslv3 |
boost::asio::ssl::context::single_dh_use);
ctx->set_password_callback(bind(&get_password));
ctx->use_certificate_chain_file("server.pem");
ctx->use_private_key_file("server.pem", boost::asio::ssl::context::pem);
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
}
return ctx;
}
int main() {
// set up an external io_service to run both endpoints on. This is not
// strictly necessary, but simplifies thread management a bit.
boost::asio::io_service ios;
// set up plain endpoint
server_plain endpoint_plain;
// initialize asio with our external io_service rather than an internal one
endpoint_plain.init_asio(&ios);
endpoint_plain.set_message_handler(
bind(&on_message<server_plain>,&endpoint_plain,::_1,::_2));
endpoint_plain.listen(80);
endpoint_plain.start_accept();
// set up tls endpoint
server_tls endpoint_tls;
endpoint_tls.init_asio(&ios);
endpoint_tls.set_message_handler(
bind(&on_message<server_tls>,&endpoint_tls,::_1,::_2));
// TLS endpoint has an extra handler for the tls init
endpoint_tls.set_tls_init_handler(bind(&on_tls_init,::_1));
// tls endpoint listens on a different port
endpoint_tls.listen(443);
endpoint_tls.start_accept();
// Start the ASIO io_service run loop running both endpoints
ios.run();
}
+58
View File
@@ -0,0 +1,58 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,A0ED66EF872A48A9
gXuvKojXzApVhhPVNdRliiajbC4PtwQG5c8TA7JADLgwOR7o9t6KtXEr37bDRpvB
9aO9P+SJaK5OOp3XKPGthOdqv+tvCRTlmzmC8GjPLBX389DWT2xoGu7JkGwDtdSm
rnF49Rlp5bfjpACk5xKNiKeDo1CWfeEJzw9Kto0g+5eMaEdors64oPzjXs3geA2g
TxCJSHv9qSX6++pCLKKCUTbyzidAxV/Zb0AAubt5V40QKqX4HhSwwstFnTaX3tlb
3QOdY+y04VIkM6d7qN5W8M7NzRkMpZ1qBpQcUMpkhQcRzWP2wub5AAff9D2GntRd
4Dz1vn3u41U3Okdr0CNj+iH7byCzuokoAhk6ZQEN6WB+GTpGgfBXdtUZrfpb0MKm
UNYP5AF2AmUqJRXhViTDVtu/V2tHF3LGuNT+W2Dz+spFZEq0byEO0N858eR0dikc
6jOASvNQbSwD0+mkgBC1gXKKU3ngj2gpJUwljeACdWFd8N2egrZfyI05CmX7vPNC
NXbs7k2buWNdjP4/D8IM+HDVidWzQa/kG/qokXKqllem9Egg37lUucwnP3cX2/Hw
U2mfaBWzeZtqc+GqRp08rYIql+Reai3sUYlQMnNk01prVY47UQb+dxuqjaxGV5Xx
Xkx0s2mfQnNRjL4S7Hjhqelufi6GpkCQ2EGsPpA+6K1ztZ0ame9Q2BE1SXeM/6vU
rxT5nRrCxueyXAyQSGcqMX9//gSeK8WWBqG/c1IAMVDa0NWrJeOJhSziE+ta3B0m
bHAPBY6vh0iB3lLdRlbUOPbC6R1TpxMOs+6Vbs2+OTifFpvOVymEoZq/nroyg68P
vn5uCKogwWA7o8EArf/UTlIwWJmH9bgILdZKld4wMel2HQg16RDzm+mEXAJi52a/
FC+fgfphdxltmUJ+rqOyR4AHULjaTWUQqTIB6sdlzgmES1nXAiE71zX//KFqomar
O60SPPk3C1bs0x5DsvmGJa8SIfDhyd+D7NPyqwEKqrZsaotYGklNkfqxa6pa8mrc
ejxquW1PK4FvBk26+osu5a90Jih0PcQM7DUMMr2WHdTiMSXWAiK2ToYF8Itt25Qv
Cd0CsSYw9CJkXNr1u1+mObheaY9QYOmztnSJLy4ZO2JsMhqNwuAueIcwmhXOREq7
kzlnGMgJcuSeAS/OBNj8Zgx0c7QQ0kzc+YmnOCsqoMtPsu/CsXJ4iJiM3Tki/2jT
bywrTiQwE6R3a/87GREOREX+WLicZBWX3k9/4tBL5XSe1p5wPpuIRQUDvAGNfNHP
JN7kujDF4SehilF1qtvCygAwvxHFDj+EwhXKNDKJzoZZIM15rAk3k92n2j6nz1qH
a3xOU05yydOlO6F6w51I1QoDddmkzCRNB0TeO3D6rekHsCK1aDWmC+qRcm2ZFtVz
sY6fdZN2NEmMQokIh9Opi1f8CSYSizPESMzdu2SF0xVO9n/IGIkn1ksK04O2BZo0
X3LBPHLfCRsQNY1eF17bj07fYU2oPZKs/XzJiwxkqK6LFvpeAVaYrtg9fqRO/UVe
QhUIj3BL550ocEpa15xLehLrmwzYiW5zwGjSHQ4EgZluGLCwyKGTh4QswEJRA9Rt
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIE0DCCA7igAwIBAgIJAM5MuKJezXq0MA0GCSqGSIb3DQEBBQUAMIGgMQswCQYD
VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xGDAW
BgNVBAoTD1phcGhveWQgU3R1ZGlvczEUMBIGA1UECxMLV2ViU29ja2V0KysxFjAU
BgNVBAMTDVBldGVyIFRob3Jzb24xJDAiBgkqhkiG9w0BCQEWFXdlYm1hc3RlckB6
YXBob3lkLmNvbTAeFw0xMTExMTUyMTIwMDZaFw0xMjExMTQyMTIwMDZaMIGgMQsw
CQYDVQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28x
GDAWBgNVBAoTD1phcGhveWQgU3R1ZGlvczEUMBIGA1UECxMLV2ViU29ja2V0Kysx
FjAUBgNVBAMTDVBldGVyIFRob3Jzb24xJDAiBgkqhkiG9w0BCQEWFXdlYm1hc3Rl
ckB6YXBob3lkLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANR0
tdwAnIB8I9qRZ7QbzEWY95RpM7GIn0u/9oH90PzdHiE0rXSkKT+yw3XUzH0iw5t0
5dEwSC+srSP5Vm4cA6kXc94agVVaPW89tGcdP4fHptCruSrzQsDXELCPl5UUvMpA
YUcGisdXYPN/EeOoqb9wKWxoW5mREsyyeWWS89fYN5qU/d0QpbSvEWghqLbL/ZS2
hOlXT9LufOeA+vHiV1/T/h5xC7ecIH02YDQw1EnqxbPmkLPcWThztLS9FiufNDRM
Rhcoaj2b9VDHvDwdbeA0T5v5qNdG34LaapYOelxzQMOtM0f9Dgqehodyxl2qm9mR
lq432dlOEzDnVCPNHwECAwEAAaOCAQkwggEFMB0GA1UdDgQWBBTTPKfNMnKOykhv
+vKS7vql5JsMyzCB1QYDVR0jBIHNMIHKgBTTPKfNMnKOykhv+vKS7vql5JsMy6GB
pqSBozCBoDELMAkGA1UEBhMCVVMxETAPBgNVBAgTCElsbGlub2lzMRAwDgYDVQQH
EwdDaGljYWdvMRgwFgYDVQQKEw9aYXBob3lkIFN0dWRpb3MxFDASBgNVBAsTC1dl
YlNvY2tldCsrMRYwFAYDVQQDEw1QZXRlciBUaG9yc29uMSQwIgYJKoZIhvcNAQkB
FhV3ZWJtYXN0ZXJAemFwaG95ZC5jb22CCQDOTLiiXs16tDAMBgNVHRMEBTADAQH/
MA0GCSqGSIb3DQEBBQUAA4IBAQB+SH0s/hrv5VYqgX6SNLzxdSLvCVsUkCdTpxwY
wOJ84XmYcXDMhKDtZqLtOtN6pfEwVusFlC9mkieuunztCnWNmsSG83RuljJPjFSi
1d4Id4bKEQkQ4cfnjoHKivRrViWLnxuNnLzC6tpyGH/35kKWhhr6T58AXerFgVw3
mHvLPTr1DuhdAZA0ZuvuseVAFFAjI3RetSySwHJE3ak8KswDVfLi6E3XxMVsIWTS
/iFsC2WwoZQlljya2V/kRYIhu+uCdqJ01wunn2BvmURPSgr4GTBF0FQ9JGpNbXxM
TAU7oQJgyFc5sCcuEgPTO0dWVQTvdZVgay4tkmduKDRkmJBF
-----END CERTIFICATE-----
+18
View File
@@ -0,0 +1,18 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
if (OPENSSL_FOUND)
init_target (echo_server_tls)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
link_openssl()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
endif()
+24
View File
@@ -0,0 +1,24 @@
## Main development example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
Import('tls_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env_cpp11.Program('echo_server_tls', ["echo_server_tls.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env.Program('echo_server_tls', ["echo_server_tls.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+8
View File
@@ -0,0 +1,8 @@
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAqxMGKZB8YNV8WQnbJWwwwmifc+PfVRtd1FN5v5aQSsf6dpjX3Zlh
N1NmgecsQyg4u2EWe4Umta10QzCgYaxf6QdTCg7iprLzFNw7IvWYbQ6du12NMGDr
hmwA6KQKwbTgPL6mSlSlcK2wTP2FzxDTNffFu10cB/6Fj4kdQjPG0c1Koz/z7OOq
BuDElJLClS8rjp3z1xvrc7gX95dFa2KaKgOAYDkpe8tfHRhHfJeIVS/whH9hzx6r
OBg+E5K9JyvayrUoKgPeptRKCqo8A4YevtMLpRxMup0nMUgAIv6+BGTwPAFpwgl/
8UIVcvjh1v95PwGDM/Q8yvIBJznBYk/e2wIBAg==
-----END DH PARAMETERS-----
@@ -0,0 +1,154 @@
/*
* Copyright (c) 2015, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/**
* NOTES
*
* This example uses a number of standard classes through the websocketpp::lib
* namespace. This is to allow easy switching between Boost, the C++11 STL, and
* the standalone Asio library. Your program need not use these namespaces if
* you do not need this sort of flexibility.
*/
#include <websocketpp/config/asio.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
typedef websocketpp::server<websocketpp::config::asio_tls> server;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef websocketpp::config::asio::message_type::ptr message_ptr;
typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr;
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
std::cout << "on_message called with hdl: " << hdl.lock().get()
<< " and message: " << msg->get_payload()
<< std::endl;
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (websocketpp::exception const & e) {
std::cout << "Echo failed because: "
<< "(" << e.what() << ")" << std::endl;
}
}
void on_http(server* s, websocketpp::connection_hdl hdl) {
server::connection_ptr con = s->get_con_from_hdl(hdl);
con->set_body("Hello World!");
con->set_status(websocketpp::http::status_code::ok);
}
std::string get_password() {
return "test";
}
// See https://wiki.mozilla.org/Security/Server_Side_TLS for more details about
// the TLS modes. The code below demonstrates how to implement both the modern
enum tls_mode {
MOZILLA_INTERMEDIATE = 1,
MOZILLA_MODERN = 2
};
context_ptr on_tls_init(tls_mode mode, websocketpp::connection_hdl hdl) {
namespace asio = websocketpp::lib::asio;
std::cout << "on_tls_init called with hdl: " << hdl.lock().get() << std::endl;
std::cout << "using TLS mode: " << (mode == MOZILLA_MODERN ? "Mozilla Modern" : "Mozilla Intermediate") << std::endl;
context_ptr ctx = websocketpp::lib::make_shared<asio::ssl::context>(asio::ssl::context::sslv23);
try {
if (mode == MOZILLA_MODERN) {
// Modern disables TLSv1
ctx->set_options(asio::ssl::context::default_workarounds |
asio::ssl::context::no_sslv2 |
asio::ssl::context::no_sslv3 |
asio::ssl::context::no_tlsv1 |
asio::ssl::context::single_dh_use);
} else {
ctx->set_options(asio::ssl::context::default_workarounds |
asio::ssl::context::no_sslv2 |
asio::ssl::context::no_sslv3 |
asio::ssl::context::single_dh_use);
}
ctx->set_password_callback(bind(&get_password));
ctx->use_certificate_chain_file("server.pem");
ctx->use_private_key_file("server.pem", asio::ssl::context::pem);
// Example method of generating this file:
// `openssl dhparam -out dh.pem 2048`
// Mozilla Intermediate suggests 1024 as the minimum size to use
// Mozilla Modern suggests 2048 as the minimum size to use.
ctx->use_tmp_dh_file("dh.pem");
std::string ciphers;
if (mode == MOZILLA_MODERN) {
ciphers = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK";
} else {
ciphers = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA";
}
if (SSL_CTX_set_cipher_list(ctx->native_handle() , ciphers.c_str()) != 1) {
std::cout << "Error setting cipher list" << std::endl;
}
} catch (std::exception& e) {
std::cout << "Exception: " << e.what() << std::endl;
}
return ctx;
}
int main() {
// Create a server endpoint
server echo_server;
// Initialize ASIO
echo_server.init_asio();
// Register our message handler
echo_server.set_message_handler(bind(&on_message,&echo_server,::_1,::_2));
echo_server.set_http_handler(bind(&on_http,&echo_server,::_1));
echo_server.set_tls_init_handler(bind(&on_tls_init,MOZILLA_INTERMEDIATE,::_1));
// Listen on port 9002
echo_server.listen(9002);
// Start the server accept loop
echo_server.start_accept();
// Start the ASIO io_service run loop
echo_server.run();
}
+57
View File
@@ -0,0 +1,57 @@
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDMYjHlTUeUGSys
Fz5PZcvgS3gojBlEAOu2gXFQDcJ7kq6dJ4jKsPaH1Q5jAtEDkU/el8otzfacOgyp
2ZxioRimpmcORWGU0bKJcenh4ZQ1oK1CQObjeYk1YgE7H8/sBetSdtL4n1rB8LIz
AV/k6kwSZFu3/lSmc6g09H4efSKGKVBcVOjBamcvFGVH4KhM2NyL+ffeV5H2Ucxk
ipyhpr4uxEoC3EV60sQxloqZb+upBM0LS4kVvaYMcn39XkUx3Z8FwN5+hFGwsWda
tU8zDxEuRMrZxG7mwDXLBGehtQvoJIVMQbOuwBQcgAbsVyy1dxV3aczbLX0iGEuG
eBhdFE+BAgMBAAECggEAQaPn0nUXYAEVz89HO8i9ybNzS9Jy6txA18SK1+MTawyY
9/AShsZ+5vEORc5JwpOQyzSEwmE7qsEaABLbnvGOMTeQMY0m4dzXMj1bmCgSqYaJ
HpYpkTUfU/2913dIF81u3nU7HI5RX6gmEyuF2MdG10FUE6ujFDJg+2DqgHA//kYD
hkXFinVS2PuZs8d5xdzpF0aCIWTuOc+Fgsyhdm/lZRIzFdID45YUVuPIN2uh+GkM
ENp/r1x7dPlDRqiL1ufP0mTQGs26S5kQSF8W0BClkOIOgmrhSON4+Vqhqx+ki/7w
RY+7mmgdvt0uzYT+Lk2cDw4f89Rsh7rR1EieBpQ2YQKBgQDq6zAHWfweJmkugT0w
HzI0UKfcOdzlJBwMu6tSgSHU99dnXlTwQY8sG7vtfRekokoo7XY4JsSk1n6E9OVy
4UKuEvU1+llDGxtvHxEEGOAgwB8wxMuY4uNYgDVhTlUzr2ERcet7FOIGzxEWzSsg
5vgnTQfyMzAh5/6k8CsHVI4u2wKBgQDeuYVCgg555lcc5rvTFxfU15d3fweSd78+
akgIBaXAlFbxI+5znGPmKG/ii4N2XObC8B568fA2nIxw6M1xgbKyvvmN3ECYiqWv
bx8x6Vg5Slg0vJr+DrPgvIKbOWEEKF/cfpTeeVLP0gUBT63mA3qezuRx1r0JJr7A
k9a4Td9j0wKBgDmRQMfMaVgKGaRnz1LHkkn3qerx0wvj+Wu1YZpqQpwp0ANovm/R
4P/yG+9qxCx4CKxW5K2F8pJibcavLLsmMGzwAF8l5lHnhqWIe2cBoYrlCb+tuibR
Et1RLcOWqpJr2+GmhQo4Z9s7SvjHdlYtw4n9+oCDwrvMWj6ZDDJTqjQZAoGAEhRt
RODZ2/texvHT/Wa6gISfvwuIydL+q0plXoFW2zMve5O3H5tqYJyXuIQqv8j60og7
cS+CmGxM2j2Lr9MfdnMaPvHKLJfUq1ER7zNJ/hyS3HUS/9yhrXSgBYm63mOIpJWB
8C1ZE5Ww4lJdg3Z01b9lu/f6kGucwHU/0OZBZBECgYAQ+dl2kKKd+lQ9O/LVz7oD
goQMPYF+QZcEhY4vlYKkWVtR2A0CiY6XeTi6vO/qVUt/ht+UO3XIJFOjGV1VyORQ
Bhibfstxl5s59jGlns5y5QqcRKzCiX74BKG0xQUtHgga7Od6L+GJKbJAPBfncYwW
U7Tfwwi0WbbgQoy5Xr/5gg==
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIFBTCCAu2gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVT
MQswCQYDVQQIDAJJTDEUMBIGA1UECgwLV2ViU29ja2V0KysxKjAoBgNVBAsMIVdl
YlNvY2tldCsrIENlcnRpZmljYXRlIEF1dGhvcml0eTEkMCIGA1UEAwwbV2ViU29j
a2V0KysgSW50ZXJtZWRpYXRlIENBMB4XDTE2MDYwODEyNDUxMloXDTI2MDYwNjEy
NDUxMlowfjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAklMMRAwDgYDVQQHDAdDaGlj
YWdvMRQwEgYDVQQKDAtXZWJTb2NrZXQrKzEgMB4GA1UECwwXV2ViU29ja2V0Kysg
VExTIEV4YW1wbGUxGDAWBgNVBAMMD3dlYnNvY2tldHBwLm9yZzCCASIwDQYJKoZI
hvcNAQEBBQADggEPADCCAQoCggEBAMxiMeVNR5QZLKwXPk9ly+BLeCiMGUQA67aB
cVANwnuSrp0niMqw9ofVDmMC0QORT96Xyi3N9pw6DKnZnGKhGKamZw5FYZTRsolx
6eHhlDWgrUJA5uN5iTViATsfz+wF61J20vifWsHwsjMBX+TqTBJkW7f+VKZzqDT0
fh59IoYpUFxU6MFqZy8UZUfgqEzY3Iv5995XkfZRzGSKnKGmvi7ESgLcRXrSxDGW
iplv66kEzQtLiRW9pgxyff1eRTHdnwXA3n6EUbCxZ1q1TzMPES5EytnEbubANcsE
Z6G1C+gkhUxBs67AFByABuxXLLV3FXdpzNstfSIYS4Z4GF0UT4ECAwEAAaOBhzCB
hDALBgNVHQ8EBAMCBDAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwYAYDVR0RBFkwV4IP
d2Vic29ja2V0cHAub3JnghN3d3cud2Vic29ja2V0cHAub3Jnghl1dGlsaXRpZXMu
d2Vic29ja2V0cHAub3JnghRkb2NzLndlYnNvY2tldHBwLm9yZzANBgkqhkiG9w0B
AQsFAAOCAgEAelJvIWFikBU3HVoP0icuoezTHGqABPLCeooTC/GELq7lHCFEjiqW
p96Zc3vrk+0Z0tkYy3E0fpuzPtlTUhBzO3fMF41FpB5ix3W/tH9YJvrozlIuDD1I
IEusxomeeiMRbyYpX/gkSOO74ylCzMEQVzleMNdpzpeXOg0Kp5z2JNShdEoT7eMR
qkJQJjMdL6QeXUqWNvX1Zqb8v6VeWGWjuu/cl374P8D8bjn89VwZQ5HFqoLOhI5v
XEYsMViZWwLSMcfWTU2Rdi0RxUZQVciLP/3GQROR1/0/e1J1kd7GsRWQMZcU20Vy
jXBVAiWhW1bgd0XOrrFILsAmnBtinEJiE+h5UC4ksZtwWf9x1IhXGlpb9bmD4+Ud
93wmqytPXBFL6wwlj4IYjjy0gU6xP6h7nwhHXnBlwFWGDpe8Cco9qgyJxJxBTtj9
MbBv+BSLXJoniDASdk6RIqCjPWZtWbQ7j5mIKV0bdJQZpBX553QOy8AoIpJE32An
FzR0SSCHOCgSAbqtM8CvLO6mquEJunmwKQx6xfos5N6ee+D+JtUFTw04TrjZUzFs
Z7v3SN/N4Hd13iTBDSu4XY/tJYICvTRLYNrzQRh/XEVbEEVxXhL8rxNn5aL1pqrV
yEnvHXrnSXWxTif1K+hS2HfTkQ6d1GjglvmwkoBqBHuRH0OJ1VguTqM=
-----END CERTIFICATE-----
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (enriched_storage)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
@@ -0,0 +1,87 @@
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
struct connection_data {
int sessionid;
std::string name;
};
struct custom_config : public websocketpp::config::asio {
// pull default settings from our core config
typedef websocketpp::config::asio core;
typedef core::concurrency_type concurrency_type;
typedef core::request_type request_type;
typedef core::response_type response_type;
typedef core::message_type message_type;
typedef core::con_msg_manager_type con_msg_manager_type;
typedef core::endpoint_msg_manager_type endpoint_msg_manager_type;
typedef core::alog_type alog_type;
typedef core::elog_type elog_type;
typedef core::rng_type rng_type;
typedef core::transport_type transport_type;
typedef core::endpoint_base endpoint_base;
// Set a custom connection_base class
typedef connection_data connection_base;
};
typedef websocketpp::server<custom_config> server;
typedef server::connection_ptr connection_ptr;
using websocketpp::connection_hdl;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
class print_server {
public:
print_server() : m_next_sessionid(1) {
m_server.init_asio();
m_server.set_open_handler(bind(&print_server::on_open,this,::_1));
m_server.set_close_handler(bind(&print_server::on_close,this,::_1));
m_server.set_message_handler(bind(&print_server::on_message,this,::_1,::_2));
}
void on_open(connection_hdl hdl) {
connection_ptr con = m_server.get_con_from_hdl(hdl);
con->sessionid = m_next_sessionid++;
}
void on_close(connection_hdl hdl) {
connection_ptr con = m_server.get_con_from_hdl(hdl);
std::cout << "Closing connection " << con->name
<< " with sessionid " << con->sessionid << std::endl;
}
void on_message(connection_hdl hdl, server::message_ptr msg) {
connection_ptr con = m_server.get_con_from_hdl(hdl);
if (con->name.empty()) {
con->name = msg->get_payload();
std::cout << "Setting name of connection with sessionid "
<< con->sessionid << " to " << con->name << std::endl;
} else {
std::cout << "Got a message from connection " << con->name
<< " with sessionid " << con->sessionid << std::endl;
}
}
void run(uint16_t port) {
m_server.listen(port);
m_server.start_accept();
m_server.run();
}
private:
int m_next_sessionid;
server m_server;
};
int main() {
print_server server;
server.run(9002);
}
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (external_io_service)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+23
View File
@@ -0,0 +1,23 @@
## Main development example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('external_io_service', ["external_io_service.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('external_io_service', ["external_io_service.cpp"], LIBS = ALL_LIBS)
Return('prgs')
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2015, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "tcp_echo_server.hpp"
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
typedef websocketpp::server<websocketpp::config::asio> ws_echo_server;
// Define a callback to handle incoming messages
void on_message(ws_echo_server* s, websocketpp::connection_hdl hdl, ws_echo_server::message_ptr msg) {
std::cout << "on_message called with hdl: " << hdl.lock().get()
<< " and message: " << msg->get_payload()
<< std::endl;
// check for a special command to instruct the server to stop listening so
// it can be cleanly exited.
if (msg->get_payload() == "stop-listening") {
s->stop_listening();
return;
}
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (websocketpp::exception const & e) {
std::cout << "Echo failed because: "
<< "(" << e.what() << ")" << std::endl;
}
}
int main() {
asio::io_service service;
// Add a TCP echo server on port 9003
tcp_echo_server custom_http_server(service, 9003);
// Add a WebSocket echo server on port 9002
ws_echo_server ws_server;
ws_server.set_access_channels(websocketpp::log::alevel::all);
ws_server.clear_access_channels(websocketpp::log::alevel::frame_payload);
// The only difference in this code between an internal and external
// io_service is the different constructor to init_asio
ws_server.init_asio(&service);
// Register our message handler
ws_server.set_message_handler(bind(&on_message,&ws_server,::_1,::_2));
ws_server.listen(9002);
ws_server.start_accept();
// TODO: add a timer?
// Start the Asio io_service run loop for all
service.run();
}
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2015, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* TCP Echo Server
*
* This file defines a simple TCP Echo Server. It is adapted from the Asio
* example: cpp03/echo/async_tcp_echo_server.cpp
*/
#include <websocketpp/common/asio.hpp>
#include <websocketpp/common/memory.hpp>
#include <websocketpp/common/functional.hpp>
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
namespace asio = websocketpp::lib::asio;
struct tcp_echo_session : websocketpp::lib::enable_shared_from_this<tcp_echo_session> {
typedef websocketpp::lib::shared_ptr<tcp_echo_session> ptr;
tcp_echo_session(asio::io_service & service) : m_socket(service) {}
void start() {
m_socket.async_read_some(asio::buffer(m_buffer, sizeof(m_buffer)),
websocketpp::lib::bind(
&tcp_echo_session::handle_read, shared_from_this(), _1, _2));
}
void handle_read(const asio::error_code & ec, size_t transferred) {
if (!ec) {
asio::async_write(m_socket,
asio::buffer(m_buffer, transferred),
bind(&tcp_echo_session::handle_write, shared_from_this(), _1));
}
}
void handle_write(const asio::error_code & ec) {
if (!ec) {
m_socket.async_read_some(asio::buffer(m_buffer, sizeof(m_buffer)),
bind(&tcp_echo_session::handle_read, shared_from_this(), _1, _2));
}
}
asio::ip::tcp::socket m_socket;
char m_buffer[1024];
};
struct tcp_echo_server {
tcp_echo_server(asio::io_service & service, short port)
: m_service(service)
, m_acceptor(service, asio::ip::tcp::endpoint(asio::ip::tcp::v6(), port))
{
this->start_accept();
}
void start_accept() {
tcp_echo_session::ptr new_session(new tcp_echo_session(m_service));
m_acceptor.async_accept(new_session->m_socket,
bind(&tcp_echo_server::handle_accept, this, new_session, _1));
}
void handle_accept(tcp_echo_session::ptr new_session, const asio::error_code & ec) {
if (!ec) {
new_session->start();
}
start_accept();
}
asio::io_service & m_service;
asio::ip::tcp::acceptor m_acceptor;
};
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (handler_switch)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
@@ -0,0 +1,42 @@
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
using websocketpp::connection_hdl;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
using websocketpp::lib::ref;
void custom_on_msg(server & s, connection_hdl hdl, server::message_ptr msg) {
std::cout << "Message sent to custom handler" << std::endl;
}
void default_on_msg(server & s, connection_hdl hdl, server::message_ptr msg) {
std::cout << "Message sent to default handler" << std::endl;
if (msg->get_payload() == "upgrade") {
// Upgrade our connection_hdl to a full connection_ptr
server::connection_ptr con = s.get_con_from_hdl(hdl);
// Change the on message handler for this connection only to
// custom_on_mesage
con->set_message_handler(bind(&custom_on_msg,ref(s),::_1,::_2));
std::cout << "Upgrading connection to custom handler" << std::endl;
}
}
int main() {
server s;
s.set_message_handler(bind(&default_on_msg,ref(s),::_1,::_2));
s.init_asio();
s.listen(9002);
s.start_accept();
s.run();
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (iostream_server)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+23
View File
@@ -0,0 +1,23 @@
## iostream server example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('iostream_server', ["iostream_server.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('iostream_server', ["iostream_server.cpp"], LIBS = ALL_LIBS)
Return('prgs')
@@ -0,0 +1,89 @@
#include <websocketpp/config/core.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
#include <fstream>
typedef websocketpp::server<websocketpp::config::core> server;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef server::message_ptr message_ptr;
// Define a callback to handle incoming messages
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
if (msg->get_opcode() == websocketpp::frame::opcode::text) {
s->get_alog().write(websocketpp::log::alevel::app,
"Text Message Received: "+msg->get_payload());
} else {
s->get_alog().write(websocketpp::log::alevel::app,
"Binary Message Received: "+websocketpp::utility::to_hex(msg->get_payload()));
}
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (websocketpp::exception const & e) {
s->get_alog().write(websocketpp::log::alevel::app,
std::string("Echo Failed: ")+e.what());
}
}
int main() {
server s;
std::ofstream log;
try {
// set up access channels to only log interesting things
s.clear_access_channels(websocketpp::log::alevel::all);
s.set_access_channels(websocketpp::log::alevel::connect);
s.set_access_channels(websocketpp::log::alevel::disconnect);
s.set_access_channels(websocketpp::log::alevel::app);
// Log to a file rather than stdout, as we are using stdout for real
// output
log.open("output.log");
s.get_alog().set_ostream(&log);
s.get_elog().set_ostream(&log);
// print all output to stdout
s.register_ostream(&std::cout);
// Register our message handler
s.set_message_handler(bind(&on_message,&s,::_1,::_2));
server::connection_ptr con = s.get_connection();
con->start();
// C++ iostream's don't support the idea of asynchronous i/o. As such
// there are two input strategies demonstrated here. Buffered I/O will
// read from stdin in chunks until EOF. This works very well for
// replaying canned connections as would be done in automated testing.
//
// If the server is being used live however, assuming input is being
// piped from elsewhere in realtime, this strategy will result in small
// messages being buffered forever. The non-buffered strategy below
// reads characters from stdin one at a time. This is inefficient and
// for more serious uses should be replaced with a platform specific
// asyncronous i/o technique like select, poll, IOCP, etc
bool buffered_io = false;
if (buffered_io) {
std::cin >> *con;
con->eof();
} else {
char a;
while(std::cin.get(a)) {
con->read_some(&a,1);
}
con->eof();
}
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
}
log.close();
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (print_client)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+23
View File
@@ -0,0 +1,23 @@
## Print client example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('print_client', ["print_client.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('print_client', ["print_client.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+78
View File
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2016, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
#include <iostream>
typedef websocketpp::client<websocketpp::config::asio_client> client;
void on_message(websocketpp::connection_hdl, client::message_ptr msg) {
std::cout << msg->get_payload() << std::endl;
}
int main(int argc, char* argv[]) {
client c;
std::string uri = "ws://localhost:9002";
if (argc == 2) {
uri = argv[1];
}
try {
// Set logging to be pretty verbose (everything except message payloads)
c.set_access_channels(websocketpp::log::alevel::all);
c.clear_access_channels(websocketpp::log::alevel::frame_payload);
c.set_error_channels(websocketpp::log::elevel::all);
// Initialize ASIO
c.init_asio();
// Register our message handler
c.set_message_handler(&on_message);
websocketpp::lib::error_code ec;
client::connection_ptr con = c.get_connection(uri, ec);
if (ec) {
std::cout << "could not create connection because: " << ec.message() << std::endl;
return 0;
}
// Note that connect here only requests a connection. No network messages are
// exchanged until the event loop starts running in the next line.
c.connect(con);
// Start the ASIO io_service run loop
// this will cause a single connection to be made to the server. c.run()
// will exit when this connection is closed.
c.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
}
}
+17
View File
@@ -0,0 +1,17 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
if (OPENSSL_FOUND)
init_target (print_client_tls)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
link_openssl()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
endif()
+24
View File
@@ -0,0 +1,24 @@
## Print client tls example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
Import('tls_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env_cpp11.Program('print_client_tls', ["print_client_tls.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env.Program('print_client_tls', ["print_client_tls.cpp"], LIBS = ALL_LIBS)
Return('prgs')
@@ -0,0 +1,66 @@
-----BEGIN CERTIFICATE-----
MIIFxTCCA62gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwYDELMAkGA1UEBhMCVVMx
CzAJBgNVBAgMAklMMRAwDgYDVQQHDAdDaGljYWdvMRQwEgYDVQQKDAtXZWJTb2Nr
ZXQrKzEcMBoGA1UEAwwTV2ViU29ja2V0KysgUm9vdCBDQTAeFw0xNjA1MjUxMzU4
MjdaFw0yNjA1MjMxMzU4MjdaMIGCMQswCQYDVQQGEwJVUzELMAkGA1UECAwCSUwx
FDASBgNVBAoMC1dlYlNvY2tldCsrMSowKAYDVQQLDCFXZWJTb2NrZXQrKyBDZXJ0
aWZpY2F0ZSBBdXRob3JpdHkxJDAiBgNVBAMMG1dlYlNvY2tldCsrIEludGVybWVk
aWF0ZSBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMNaFAzlx0KJ
gG15yRHI3xn9+B1woHG4uuOr124Sk1JllPcO3enusgIYTMl0FiYYW9CsyPoe4L0P
wflbz20vDDjxmXG+NPgjuYmnPaq7q2JXYz+cShv9+o60EIwEIe+EWk1ZQs9YSdQ0
r4UOxGVq6eEuWJi8Wh02cbnxdjwvrk7lTMFVY+z5EX8cCj6Tbrd0lyIf/0X8OkOb
q2HOqqzTgT2apBCWCEW6grW6rtMOoDx93BOZDBEGz39sJ5i8AQ8XIdYCdUcOMdJU
SCAw/MMyFTHXhv8hJdG5GcDSfc7woB9xRUf8UHuCH0nYkTb260TWvyDCYJy001ko
SWoRbh2hVgPqQ9FTDMzMTY8T8C5u3BRfGN5PHuSPhwfHv/p1g4uPnltDBe4CNtOs
wu8w1wbrr3uI7qETnqOzbXlcT7o4rCrrRQqLbNOssf2mMH+Phq6dINjXpZjiAhO0
SURtBMmQdAZcQkGStzFitEkb2Py5LEIxQ068i8RCowTyD9+/jbO1fZyxJ4X8TDUe
Xx48xWnu0i4f8/9ldnWLwX9h3ilaZVsr7buNYJoMlz+v73TQoWKSybJ2SMe/Cddj
OZCy5r1UakuZhX6n1ScD/hbO8FEfmQRpAywYajyU4dZ9XMbf5bo6OAUqlJ2f4yYh
VAy5mi1JHfD5PiJN90j79GXXvtBTJc4hAgMBAAGjZjBkMB0GA1UdDgQWBBTKMn5O
3NUPpztL1bAz8UCsOBLpkjAfBgNVHSMEGDAWgBTNBBKZQN694xplMGyMruXFv27o
eTASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0B
AQsFAAOCAgEAyNkZUEAdP73th4/RLu0d2foMiIqKlcvw3JsW0tto3MT5lvQ5UugH
OwluhWhnMLE0KsknQd7/p4ZwyZugWAYjGcDydp0GDIDfNBBEOQkOAL23KkYiRFqt
VPBTZi9S7P2MJLY0j94liIg94nikhz/0q7JxxWFlvSHUjwZxXrbFjfZRPOS1vIq/
/VK2QjUsdIXE3NOPYfQwd9FpG2YS8ZcMeipwNYVAs2FBEeWzGH1j6i2hP8FFBDYP
0LTvJYOJvlCeyIvPBjKk9461/Z4CPJcKtKC59onQmiqSK/Juak/bpPoY7jJ228KG
bEBzClIEHgbDiBewFTHbyOWhW2ySRLOGsPeqKDSbm4J1N5rfKnrSQB9PfOmWoRfJ
vqPlXFSlpdgD4j/WnEumpvt78fT+cn+AkRG8tE5DQrCWZTK47TSWn902Fm0A19Rl
pSbE9qsulXurOqEuOOayrzcUmbZ/jkU+wj+/tN4Gl8K98WbjcXvwz0sRL3SgRRrI
awUdaGWKQHrTJNEOTisepUAuHVDmvuQz0j/Ru+PbB9K3GcKY6X6+o1c2JBC1V6KX
aHHZQ+xPm+VEa1pG/QVHGpt2AbGUQlXwDYtOIRwEhO27tFbH8Q68s2cMLYjsF5gd
MWuMYCPkFv10/V2f2lAIPSEzw2pldIGERcb4VG4xuD0qU+HH/aAID7k=
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFpjCCA46gAwIBAgIJAL42eqbfw976MA0GCSqGSIb3DQEBCwUAMGAxCzAJBgNV
BAYTAlVTMQswCQYDVQQIDAJJTDEQMA4GA1UEBwwHQ2hpY2FnbzEUMBIGA1UECgwL
V2ViU29ja2V0KysxHDAaBgNVBAMME1dlYlNvY2tldCsrIFJvb3QgQ0EwHhcNMTYw
NTI1MTM1MTUzWhcNMzYwNTIwMTM1MTUzWjBgMQswCQYDVQQGEwJVUzELMAkGA1UE
CAwCSUwxEDAOBgNVBAcMB0NoaWNhZ28xFDASBgNVBAoMC1dlYlNvY2tldCsrMRww
GgYDVQQDDBNXZWJTb2NrZXQrKyBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOC
Ag8AMIICCgKCAgEA4QjJ0v5yri+pAN67I/XPz88D8oIczCW96CIuwc44aDC9Kptb
9iY8xwbGCyQsFZ/1IQ74QfnXZSwq8EwedcBIdcyHdBu6qtNkCVKeDIZAMBef6Hx+
tWSe1op3sDbUlT8NHiTxZCZWk/2/yIi8yPzQTi4y1vF04vvrQS5RFomCz17kdyOa
NdxO5p+I4afdoVKtzA1aHoBqdTe7vzM3eww4AxKfgIEDdIuOGDiglI/b/frlwiOi
SfTOsPzu52TOPW2d1Ad5BG4GuMpnTUOVnc8j18w9LdeXO0J10oVyCmwiPuzFCcDB
g1xvVr5TXzIZ5J+qlso7+mUfZGH+nxOT7Tc78o1EvX6JbfQAI2PrpcksmJfFnN4l
4XnXDW/eKl8AlLUr/cW5axAfql4QHJoBCZcfYldQpMoL5R1ikLtY53cOJpycFoWm
1IEfkLBZ4C1old+KoaErG0+Aur8/kwAJGMnmMvZqGZ5pgXtVipOLy5TKuS6ZKO8g
MRzalaF/naiu3pF+/sctaqkAPvOr65WrANNGxTQ93ePdyuT6sOEUKXxaXcTtAOOM
5FCgX8dPxkOACxTrxppvb+bYmYL9GIuYDGYxSRu3Fm+04eXIh+uCqcuWPQuRPc5t
VXvk/M0fPaJvKfP6lRAoE5Dp4qPRvL6tRVtOXfP6d+O+yGnxRoLKAW7ejoMCAwEA
AaNjMGEwHQYDVR0OBBYEFM0EEplA3r3jGmUwbIyu5cW/buh5MB8GA1UdIwQYMBaA
FM0EEplA3r3jGmUwbIyu5cW/buh5MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/
BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQAQ4eY4LhW795wl9XuDVg2vOFTYmIS0
OxrunFX4f3RjddbIbXzYmQ0cJ8pJ5l7eGYcg/DYQRY4Tk6LjXMs9VhIU10akqLS4
qGE+Bmp3Jhu5NxZbKkY+k+kTAA1LYxFCjGjSV0v5QNLFULDAmGer2zWwU5DcDwwq
8yWyBuI974UyE/49/TeckfqwBrb90LL2lFEwoL86XZK2IZMPyMBC/S1X5P/Kc15Q
d8lwOPS5AirFkkrzs/px+mRia5U1uWKIPRLq9Medvjf8HR8SFWq9eRtkxiLaWyRv
HBVyVRKCubCZR8psVLK/zrF+Bc+Hr9aAi3TuqTKjIOI7hrq5oJcJpebZDNoBIqoj
kab13WcRwG+BQvuK1CEkd1aq8Nh2GX6Reb2Zv82/WntgP1a0sztbIGgrUBYQryb5
HF79v4e2byY613SiQ3lz+g/AWxaZsYH80/Zl+hEwEtU4fFz34Jcv9Kvda1JpknBT
Fi63ugfoNeNriO02AReMmDvuBG3X8RF1UQyBoTU3uZuW7X26MizEjiVCK9qaOLED
WDSEoyKLe4JKd387CVlsCY8K/6fBlFTI/hJhggDz8pZFj3n2irUI44kjgOmoxOrW
JY2jgY89AEMN9yOKkyQGara8pF9IJxTQ7jurYnWcUbompWeybJRwvWN0h+tGV+bd
l/aq/5LwL3fVpg==
-----END CERTIFICATE-----
@@ -0,0 +1,249 @@
/*
* Copyright (c) 2016, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <websocketpp/config/asio_client.hpp>
#include <websocketpp/client.hpp>
#include <iostream>
typedef websocketpp::client<websocketpp::config::asio_tls_client> client;
typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> context_ptr;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
void on_message(websocketpp::connection_hdl, client::message_ptr msg) {
std::cout << msg->get_payload() << std::endl;
}
/// Verify that one of the subject alternative names matches the given hostname
bool verify_subject_alternative_name(const char * hostname, X509 * cert) {
STACK_OF(GENERAL_NAME) * san_names = NULL;
san_names = (STACK_OF(GENERAL_NAME) *) X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL);
if (san_names == NULL) {
return false;
}
int san_names_count = sk_GENERAL_NAME_num(san_names);
bool result = false;
for (int i = 0; i < san_names_count; i++) {
const GENERAL_NAME * current_name = sk_GENERAL_NAME_value(san_names, i);
if (current_name->type != GEN_DNS) {
continue;
}
char * dns_name = (char *) ASN1_STRING_data(current_name->d.dNSName);
// Make sure there isn't an embedded NUL character in the DNS name
if (ASN1_STRING_length(current_name->d.dNSName) != strlen(dns_name)) {
break;
}
// Compare expected hostname with the CN
result = (strcasecmp(hostname, dns_name) == 0);
}
sk_GENERAL_NAME_pop_free(san_names, GENERAL_NAME_free);
return result;
}
/// Verify that the certificate common name matches the given hostname
bool verify_common_name(const char * hostname, X509 * cert) {
// Find the position of the CN field in the Subject field of the certificate
int common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name(cert), NID_commonName, -1);
if (common_name_loc < 0) {
return false;
}
// Extract the CN field
X509_NAME_ENTRY * common_name_entry = X509_NAME_get_entry(X509_get_subject_name(cert), common_name_loc);
if (common_name_entry == NULL) {
return false;
}
// Convert the CN field to a C string
ASN1_STRING * common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
if (common_name_asn1 == NULL) {
return false;
}
char * common_name_str = (char *) ASN1_STRING_data(common_name_asn1);
// Make sure there isn't an embedded NUL character in the CN
if (ASN1_STRING_length(common_name_asn1) != strlen(common_name_str)) {
return false;
}
// Compare expected hostname with the CN
return (strcasecmp(hostname, common_name_str) == 0);
}
/**
* This code is derived from examples and documentation found ato00po
* http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/example/cpp03/ssl/client.cpp
* and
* https://github.com/iSECPartners/ssl-conservatory
*/
bool verify_certificate(const char * hostname, bool preverified, boost::asio::ssl::verify_context& ctx) {
// The verify callback can be used to check whether the certificate that is
// being presented is valid for the peer. For example, RFC 2818 describes
// the steps involved in doing this for HTTPS. Consult the OpenSSL
// documentation for more details. Note that the callback is called once
// for each certificate in the certificate chain, starting from the root
// certificate authority.
// Retrieve the depth of the current cert in the chain. 0 indicates the
// actual server cert, upon which we will perform extra validation
// (specifically, ensuring that the hostname matches. For other certs we
// will use the 'preverified' flag from Asio, which incorporates a number of
// non-implementation specific OpenSSL checking, such as the formatting of
// certs and the trusted status based on the CA certs we imported earlier.
int depth = X509_STORE_CTX_get_error_depth(ctx.native_handle());
// if we are on the final cert and everything else checks out, ensure that
// the hostname is present on the list of SANs or the common name (CN).
if (depth == 0 && preverified) {
X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle());
if (verify_subject_alternative_name(hostname, cert)) {
return true;
} else if (verify_common_name(hostname, cert)) {
return true;
} else {
return false;
}
}
return preverified;
}
/// TLS Initialization handler
/**
* WebSocket++ core and the Asio Transport do not handle TLS context creation
* and setup. This callback is provided so that the end user can set up their
* TLS context using whatever settings make sense for their application.
*
* As Asio and OpenSSL do not provide great documentation for the very common
* case of connect and actually perform basic verification of server certs this
* example includes a basic implementation (using Asio and OpenSSL) of the
* following reasonable default settings and verification steps:
*
* - Disable SSLv2 and SSLv3
* - Load trusted CA certificates and verify the server cert is trusted.
* - Verify that the hostname matches either the common name or one of the
* subject alternative names on the certificate.
*
* This is not meant to be an exhaustive reference implimentation of a perfect
* TLS client, but rather a reasonable starting point for building a secure
* TLS encrypted WebSocket client.
*
* If any TLS, Asio, or OpenSSL experts feel that these settings are poor
* defaults or there are critically missing steps please open a GitHub issue
* or drop a line on the project mailing list.
*
* Note the bundled CA cert ca-chain.cert.pem is the CA cert that signed the
* cert bundled with echo_server_tls. You can use print_client_tls with this
* CA cert to connect to echo_server_tls as long as you use /etc/hosts or
* something equivilent to spoof one of the names on that cert
* (websocketpp.org, for example).
*/
context_ptr on_tls_init(const char * hostname, websocketpp::connection_hdl) {
context_ptr ctx = websocketpp::lib::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
try {
ctx->set_options(boost::asio::ssl::context::default_workarounds |
boost::asio::ssl::context::no_sslv2 |
boost::asio::ssl::context::no_sslv3 |
boost::asio::ssl::context::single_dh_use);
ctx->set_verify_mode(boost::asio::ssl::verify_peer);
ctx->set_verify_callback(bind(&verify_certificate, hostname, ::_1, ::_2));
// Here we load the CA certificates of all CA's that this client trusts.
ctx->load_verify_file("ca-chain.cert.pem");
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
}
return ctx;
}
int main(int argc, char* argv[]) {
client c;
std::string hostname = "localhost";
std::string port = "9002";
if (argc == 3) {
hostname = argv[1];
port = argv[2];
} else {
std::cout << "Usage: print_server_tls <hostname> <port>" << std::endl;
return 1;
}
std::string uri = "wss://" + hostname + ":" + port;
try {
// Set logging to be pretty verbose (everything except message payloads)
c.set_access_channels(websocketpp::log::alevel::all);
c.clear_access_channels(websocketpp::log::alevel::frame_payload);
c.set_error_channels(websocketpp::log::elevel::all);
// Initialize ASIO
c.init_asio();
// Register our message handler
c.set_message_handler(&on_message);
c.set_tls_init_handler(bind(&on_tls_init, hostname.c_str(), ::_1));
websocketpp::lib::error_code ec;
client::connection_ptr con = c.get_connection(uri, ec);
if (ec) {
std::cout << "could not create connection because: " << ec.message() << std::endl;
return 0;
}
// Note that connect here only requests a connection. No network messages are
// exchanged until the event loop starts running in the next line.
c.connect(con);
c.get_alog().write(websocketpp::log::alevel::app, "Connecting to " + uri);
// Start the ASIO io_service run loop
// this will cause a single connection to be made to the server. c.run()
// will exit when this connection is closed.
c.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
}
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (print_server)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+23
View File
@@ -0,0 +1,23 @@
## Print server example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('print_server', ["print_server.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('print_server', ["print_server.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+24
View File
@@ -0,0 +1,24 @@
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
void on_message(websocketpp::connection_hdl, server::message_ptr msg) {
std::cout << msg->get_payload() << std::endl;
}
int main() {
server print_server;
print_server.set_message_handler(&on_message);
print_server.set_access_channels(websocketpp::log::alevel::all);
print_server.set_error_channels(websocketpp::log::elevel::all);
print_server.init_asio();
print_server.listen(9002);
print_server.start_accept();
print_server.run();
}
+24
View File
@@ -0,0 +1,24 @@
## Scratch client example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
Import('tls_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs] + [tls_libs]
prgs += env_cpp11.Program('scratch_client', ["scratch_client.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system','random'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('utility_client', ["utility_client.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+270
View File
@@ -0,0 +1,270 @@
/*
* Copyright (c) 2014, Peter Thorson. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the WebSocket++ Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// **NOTE:** This file is a snapshot of the WebSocket++ utility client tutorial.
// Additional related material can be found in the tutorials/utility_client
// directory of the WebSocket++ repository.
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
#include <websocketpp/common/thread.hpp>
#include <websocketpp/common/memory.hpp>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <sstream>
typedef websocketpp::client<websocketpp::config::asio_client> client;
class connection_metadata {
public:
typedef websocketpp::lib::shared_ptr<connection_metadata> ptr;
connection_metadata(int id, websocketpp::connection_hdl hdl, std::string uri)
: m_id(id)
, m_hdl(hdl)
, m_status("Connecting")
, m_uri(uri)
, m_server("N/A")
{}
void on_open(client * c, websocketpp::connection_hdl hdl) {
m_status = "Open";
client::connection_ptr con = c->get_con_from_hdl(hdl);
m_server = con->get_response_header("Server");
}
void on_fail(client * c, websocketpp::connection_hdl hdl) {
m_status = "Failed";
client::connection_ptr con = c->get_con_from_hdl(hdl);
m_server = con->get_response_header("Server");
m_error_reason = con->get_ec().message();
}
void on_close(client * c, websocketpp::connection_hdl hdl) {
m_status = "Closed";
client::connection_ptr con = c->get_con_from_hdl(hdl);
std::stringstream s;
s << "close code: " << con->get_remote_close_code() << " ("
<< websocketpp::close::status::get_string(con->get_remote_close_code())
<< "), close reason: " << con->get_remote_close_reason();
m_error_reason = s.str();
}
websocketpp::connection_hdl get_hdl() const {
return m_hdl;
}
int get_id() const {
return m_id;
}
std::string get_status() const {
return m_status;
}
friend std::ostream & operator<< (std::ostream & out, connection_metadata const & data);
private:
int m_id;
websocketpp::connection_hdl m_hdl;
std::string m_status;
std::string m_uri;
std::string m_server;
std::string m_error_reason;
};
std::ostream & operator<< (std::ostream & out, connection_metadata const & data) {
out << "> URI: " << data.m_uri << "\n"
<< "> Status: " << data.m_status << "\n"
<< "> Remote Server: " << (data.m_server.empty() ? "None Specified" : data.m_server) << "\n"
<< "> Error/close reason: " << (data.m_error_reason.empty() ? "N/A" : data.m_error_reason);
return out;
}
class websocket_endpoint {
public:
websocket_endpoint () : m_next_id(0) {
m_endpoint.clear_access_channels(websocketpp::log::alevel::all);
m_endpoint.clear_error_channels(websocketpp::log::elevel::all);
m_endpoint.init_asio();
m_endpoint.start_perpetual();
m_thread.reset(new websocketpp::lib::thread(&client::run, &m_endpoint));
}
~websocket_endpoint() {
m_endpoint.stop_perpetual();
for (con_list::const_iterator it = m_connection_list.begin(); it != m_connection_list.end(); ++it) {
if (it->second->get_status() != "Open") {
// Only close open connections
continue;
}
std::cout << "> Closing connection " << it->second->get_id() << std::endl;
websocketpp::lib::error_code ec;
m_endpoint.close(it->second->get_hdl(), websocketpp::close::status::going_away, "", ec);
if (ec) {
std::cout << "> Error closing connection " << it->second->get_id() << ": "
<< ec.message() << std::endl;
}
}
m_thread->join();
}
int connect(std::string const & uri) {
websocketpp::lib::error_code ec;
client::connection_ptr con = m_endpoint.get_connection(uri, ec);
if (ec) {
std::cout << "> Connect initialization error: " << ec.message() << std::endl;
return -1;
}
int new_id = m_next_id++;
connection_metadata::ptr metadata_ptr(new connection_metadata(new_id, con->get_handle(), uri));
m_connection_list[new_id] = metadata_ptr;
con->set_open_handler(websocketpp::lib::bind(
&connection_metadata::on_open,
metadata_ptr,
&m_endpoint,
websocketpp::lib::placeholders::_1
));
con->set_fail_handler(websocketpp::lib::bind(
&connection_metadata::on_fail,
metadata_ptr,
&m_endpoint,
websocketpp::lib::placeholders::_1
));
con->set_close_handler(websocketpp::lib::bind(
&connection_metadata::on_close,
metadata_ptr,
&m_endpoint,
websocketpp::lib::placeholders::_1
));
m_endpoint.connect(con);
return new_id;
}
void close(int id, websocketpp::close::status::value code, std::string reason) {
websocketpp::lib::error_code ec;
con_list::iterator metadata_it = m_connection_list.find(id);
if (metadata_it == m_connection_list.end()) {
std::cout << "> No connection found with id " << id << std::endl;
return;
}
m_endpoint.close(metadata_it->second->get_hdl(), code, reason, ec);
if (ec) {
std::cout << "> Error initiating close: " << ec.message() << std::endl;
}
}
connection_metadata::ptr get_metadata(int id) const {
con_list::const_iterator metadata_it = m_connection_list.find(id);
if (metadata_it == m_connection_list.end()) {
return connection_metadata::ptr();
} else {
return metadata_it->second;
}
}
private:
typedef std::map<int,connection_metadata::ptr> con_list;
client m_endpoint;
websocketpp::lib::shared_ptr<websocketpp::lib::thread> m_thread;
con_list m_connection_list;
int m_next_id;
};
int main() {
bool done = false;
std::string input;
websocket_endpoint endpoint;
while (!done) {
std::cout << "Enter Command: ";
std::getline(std::cin, input);
if (input == "quit") {
done = true;
} else if (input == "help") {
std::cout
<< "\nCommand List:\n"
<< "connect <ws uri>\n"
<< "close <connection id> [<close code:default=1000>] [<close reason>]\n"
<< "show <connection id>\n"
<< "help: Display this help text\n"
<< "quit: Exit the program\n"
<< std::endl;
} else if (input.substr(0,7) == "connect") {
int id = endpoint.connect(input.substr(8));
if (id != -1) {
std::cout << "> Created connection with id " << id << std::endl;
}
} else if (input.substr(0,5) == "close") {
std::stringstream ss(input);
std::string cmd;
int id;
int close_code = websocketpp::close::status::normal;
std::string reason;
ss >> cmd >> id >> close_code;
std::getline(ss,reason);
endpoint.close(id, close_code, reason);
} else if (input.substr(0,4) == "show") {
int id = atoi(input.substr(5).c_str());
connection_metadata::ptr metadata = endpoint.get_metadata(id);
if (metadata) {
std::cout << *metadata << std::endl;
} else {
std::cout << "> Unknown connection id " << id << std::endl;
}
} else {
std::cout << "> Unrecognized Command" << std::endl;
}
}
return 0;
}
+24
View File
@@ -0,0 +1,24 @@
## Scratch server example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
Import('tls_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs] + [tls_libs] + ['z']
prgs += env_cpp11.Program('scratch_server', ["scratch_server.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system','regex','random'],env) + [platform_libs] + [polyfill_libs] + [tls_libs] + ['z']
prgs += env.Program('scratch_server', ["scratch_server.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+106
View File
@@ -0,0 +1,106 @@
/**
* This example is presently used as a scratch space. It may or may not be broken
* at any given time.
*/
#include <iostream>
#include <websocketpp/config/debug_asio_no_tls.hpp>
#include <websocketpp/server.hpp>
#include <websocketpp/extensions/permessage_deflate/enabled.hpp>
struct deflate_config : public websocketpp::config::debug_core {
typedef deflate_config type;
typedef debug_core base;
typedef base::concurrency_type concurrency_type;
typedef base::request_type request_type;
typedef base::response_type response_type;
typedef base::message_type message_type;
typedef base::con_msg_manager_type con_msg_manager_type;
typedef base::endpoint_msg_manager_type endpoint_msg_manager_type;
typedef base::alog_type alog_type;
typedef base::elog_type elog_type;
typedef base::rng_type rng_type;
struct transport_config : public base::transport_config {
typedef type::concurrency_type concurrency_type;
typedef type::alog_type alog_type;
typedef type::elog_type elog_type;
typedef type::request_type request_type;
typedef type::response_type response_type;
typedef websocketpp::transport::asio::basic_socket::endpoint
socket_type;
};
typedef websocketpp::transport::asio::endpoint<transport_config>
transport_type;
/// permessage_compress extension
struct permessage_deflate_config {};
typedef websocketpp::extensions::permessage_deflate::enabled
<permessage_deflate_config> permessage_deflate_type;
};
typedef websocketpp::server<deflate_config> server;
typedef server::message_ptr message_ptr;
// Define a callback to handle incoming messages
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
/*std::cout << "on_message called with hdl: " << hdl.lock().get()
<< " and message (" << msg->get_payload().size() << "): " << msg->get_payload()
<< std::endl;
*/
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (websocketpp::exception const & e) {
std::cout << "Echo failed because: "
<< "(" << e.what() << ")" << std::endl;
}
}
int main(int argc, char * argv[]) {
// Create a server endpoint
server echo_server;
try {
// Set logging settings
if (argc > 1 && std::string(argv[1]) == "-d") {
echo_server.set_access_channels(websocketpp::log::alevel::all);
echo_server.set_error_channels(websocketpp::log::elevel::all);
} else {
echo_server.set_access_channels(websocketpp::log::alevel::none);
echo_server.set_error_channels(websocketpp::log::elevel::none);
}
// Initialize ASIO
echo_server.init_asio();
// Register our message handler
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
echo_server.set_message_handler(bind(&on_message,&echo_server,_1,_2));
// Listen on port 9002
echo_server.listen(9002);
// Start the server accept loop
echo_server.start_accept();
// Start the ASIO io_service run loop
echo_server.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
} catch (const std::exception & e) {
std::cout << e.what() << std::endl;
} catch (...) {
std::cout << "other exception" << std::endl;
}
}
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (simple_broadcast_server)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
@@ -0,0 +1,51 @@
#include <set>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
using websocketpp::connection_hdl;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
class broadcast_server {
public:
broadcast_server() {
m_server.init_asio();
m_server.set_open_handler(bind(&broadcast_server::on_open,this,::_1));
m_server.set_close_handler(bind(&broadcast_server::on_close,this,::_1));
m_server.set_message_handler(bind(&broadcast_server::on_message,this,::_1,::_2));
}
void on_open(connection_hdl hdl) {
m_connections.insert(hdl);
}
void on_close(connection_hdl hdl) {
m_connections.erase(hdl);
}
void on_message(connection_hdl hdl, server::message_ptr msg) {
for (auto it : m_connections) {
m_server.send(it,msg);
}
}
void run(uint16_t port) {
m_server.listen(port);
m_server.start_accept();
m_server.run();
}
private:
typedef std::set<connection_hdl,std::owner_less<connection_hdl>> con_list;
server m_server;
con_list m_connections;
};
int main() {
broadcast_server server;
server.run(9002);
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (sip_client)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+22
View File
@@ -0,0 +1,22 @@
Checkout the project from git
At the top level, run cmake:
cmake -G 'Unix Makefiles' \
-D BUILD_EXAMPLES=ON \
-D WEBSOCKETPP_ROOT=/tmp/cm1 \
-D ENABLE_CPP11=OFF .
and then make the example:
make -C examples/sip_client
Now run it:
bin/sip_client ws://ws-server:80
It has been tested against the repro SIP proxy from reSIProcate
http://www.resiprocate.org/WebRTC_and_SIP_Over_WebSockets
+23
View File
@@ -0,0 +1,23 @@
## SIP client example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('sip_client', ["sip_client.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system','random'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('sip_client', ["sip_client.cpp"], LIBS = ALL_LIBS)
Return('prgs')
+84
View File
@@ -0,0 +1,84 @@
#include <condition_variable>
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
#include <iostream>
#include <boost/thread/thread.hpp>
typedef websocketpp::client<websocketpp::config::asio_client> client;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef websocketpp::config::asio_client::message_type::ptr message_ptr;
// Create a server endpoint
client sip_client;
bool received;
void on_open(client* c, websocketpp::connection_hdl hdl) {
// now it is safe to use the connection
std::cout << "connection ready" << std::endl;
received=false;
// Send a SIP OPTIONS message to the server:
std::string SIP_msg="OPTIONS sip:carol@chicago.com SIP/2.0\r\nVia: SIP/2.0/WS df7jal23ls0d.invalid;rport;branch=z9hG4bKhjhs8ass877\r\nMax-Forwards: 70\r\nTo: <sip:carol@chicago.com>\r\nFrom: Alice <sip:alice@atlanta.com>;tag=1928301774\r\nCall-ID: a84b4c76e66710\r\nCSeq: 63104 OPTIONS\r\nContact: <sip:alice@pc33.atlanta.com>\r\nAccept: application/sdp\r\nContent-Length: 0\r\n\r\n";
sip_client.send(hdl, SIP_msg.c_str(), websocketpp::frame::opcode::text);
}
void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) {
client::connection_ptr con = sip_client.get_con_from_hdl(hdl);
std::cout << "Received a reply:" << std::endl;
fwrite(msg->get_payload().c_str(), msg->get_payload().size(), 1, stdout);
received=true;
}
int main(int argc, char* argv[]) {
std::string uri = "ws://localhost:9001";
if (argc == 2) {
uri = argv[1];
}
try {
// We expect there to be a lot of errors, so suppress them
sip_client.clear_access_channels(websocketpp::log::alevel::all);
sip_client.clear_error_channels(websocketpp::log::elevel::all);
// Initialize ASIO
sip_client.init_asio();
// Register our handlers
sip_client.set_open_handler(bind(&on_open,&sip_client,::_1));
sip_client.set_message_handler(bind(&on_message,&sip_client,::_1,::_2));
websocketpp::lib::error_code ec;
client::connection_ptr con = sip_client.get_connection(uri, ec);
// Specify the SIP subprotocol:
con->add_subprotocol("sip");
sip_client.connect(con);
// Start the ASIO io_service run loop
sip_client.run();
while(!received) {
boost::this_thread::sleep(boost::posix_time::milliseconds(100));
}
std::cout << "done" << std::endl;
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
}
}
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (subprotocol_server)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")
+23
View File
@@ -0,0 +1,23 @@
## Main development example
##
Import('env')
Import('env_cpp11')
Import('boostlibs')
Import('platform_libs')
Import('polyfill_libs')
env = env.Clone ()
env_cpp11 = env_cpp11.Clone ()
prgs = []
# if a C++11 environment is available build using that, otherwise use boost
if env_cpp11.has_key('WSPP_CPP11_ENABLED'):
ALL_LIBS = boostlibs(['system'],env_cpp11) + [platform_libs] + [polyfill_libs]
prgs += env_cpp11.Program('subprotocol_server', ["subprotocol_server.cpp"], LIBS = ALL_LIBS)
else:
ALL_LIBS = boostlibs(['system'],env) + [platform_libs] + [polyfill_libs]
prgs += env.Program('subprotocol_server', ["subprotocol_server.cpp"], LIBS = ALL_LIBS)
Return('prgs')
@@ -0,0 +1,48 @@
#include <iostream>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
typedef websocketpp::server<websocketpp::config::asio> server;
using websocketpp::connection_hdl;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
using websocketpp::lib::ref;
bool validate(server & s, connection_hdl hdl) {
server::connection_ptr con = s.get_con_from_hdl(hdl);
std::cout << "Cache-Control: " << con->get_request_header("Cache-Control") << std::endl;
const std::vector<std::string> & subp_requests = con->get_requested_subprotocols();
std::vector<std::string>::const_iterator it;
for (it = subp_requests.begin(); it != subp_requests.end(); ++it) {
std::cout << "Requested: " << *it << std::endl;
}
if (subp_requests.size() > 0) {
con->select_subprotocol(subp_requests[0]);
}
return true;
}
int main() {
try {
server s;
s.set_validate_handler(bind(&validate,ref(s),::_1));
s.init_asio();
s.listen(9005);
s.start_accept();
s.run();
} catch (websocketpp::exception const & e) {
std::cout << e.what() << std::endl;
}
}
+12
View File
@@ -0,0 +1,12 @@
file (GLOB SOURCE_FILES *.cpp)
file (GLOB HEADER_FILES *.hpp)
init_target (telemetry_client)
build_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
link_boost ()
final_target ()
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "examples")

Some files were not shown because too many files have changed in this diff Show More