Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
254a4fa
Fixed C++ compiler warning in alignment calc
TwentyPast4 Oct 1, 2021
d8c78d4
Build fixes and data race fixed
TwentyPast4 Aug 18, 2022
d590e6a
Haiku check for -lnetwork
Begasus Nov 13, 2019
47a9d3c
Added move semantics
TwentyPast4 Aug 18, 2022
e7d3eef
Add guards for functions requiring C++11 features
Jul 26, 2020
b207cc9
[feature] Add support for exception free mode fixes #792
Jul 31, 2020
5904e8d
Fixed some no_exception cases
TwentyPast4 Aug 18, 2022
c6e1f90
Fixed boost incompatibility
TwentyPast4 Aug 18, 2022
aef0a48
Fixed shutdown problem in OpenSSL 3
TwentyPast4 Nov 7, 2022
de90527
Feature: Added deferred handshake option
TwentyPast4 Jan 3, 2023
215a278
Changed handlers to use references, reducing call overhead
TwentyPast4 Jan 4, 2023
1af6804
Added HTTP client capability
TwentyPast4 Jan 23, 2023
ef40eb7
Set HTTP version if unset
TwentyPast4 Jan 24, 2023
6a8ed96
Support chunked transfer encoding (HTTP 1.1)
TwentyPast4 Jan 25, 2023
4a2b160
Fixed parsing of requests without bodies
TwentyPast4 Jan 25, 2023
88fd69f
Set request URI if empty
TwentyPast4 Jan 25, 2023
acf4c54
Fixed URI secure flag not set correctly
TwentyPast4 Jan 25, 2023
bb0ddee
Fixed Double host entry & websocket initiator requests
TwentyPast4 Jan 25, 2023
b4f946b
Fixed relative HTTP requests
TwentyPast4 Jan 26, 2023
b96df34
Fixed multiple callbacks to m_http_handler when in client mode
TwentyPast4 Jan 27, 2023
99ab78d
Added follow HTTP redirect option
TwentyPast4 Feb 1, 2023
4fb9604
Removed typo in cmakelists
TwentyPast4 Feb 1, 2023
4fe3d8c
Fixed init handler being called twice when setting TLS SNI extension …
TwentyPast4 Feb 27, 2023
236e6b9
Use GET method for HTTP request if none provided
TwentyPast4 Mar 30, 2023
780cebe
Fixed http response timeouts
TwentyPast4 Aug 7, 2023
017b1a1
Added option to handle download progress
TwentyPast4 Sep 8, 2023
efdccb0
Fix compile warning
TwentyPast4 Oct 20, 2023
9676b09
Fixed const version of member method
TwentyPast4 Mar 12, 2024
fa804a4
Added HTTP content encoding support
TwentyPast4 Apr 15, 2024
2ad7c05
Fixed linker error
TwentyPast4 Apr 15, 2024
06e32e6
Remove usages of compress encoding
TwentyPast4 Apr 15, 2024
1d91646
feat(igplatform): Initial implementation of new deployment system (SW…
TwentyPast4 Apr 15, 2024
9eebf01
Updated CMake to minimum 3
TwentyPast4 Apr 16, 2024
2a4c4a5
Added missing cmake files to find Brotli & zstd
TwentyPast4 Apr 18, 2024
2d2a234
feat(jackpot): Support keycloak in jackpot server and client (SW-1007)
urosd May 13, 2024
a8f5de4
Merge pull request #1 from TroniusGaming/feature/sw-1007-support-keyc…
urosd May 13, 2024
41cc1d6
Renamed io_service to io_context (io_service is a deprecated name in …
TwentyPast4 May 23, 2024
da3cfbf
fix(uri): Parsing of link-local IPv6 and zoneids
TwentyPast4 Aug 21, 2024
de9b25c
Better hostname resolution errors
TwentyPast4 Aug 27, 2024
b0ac953
fix(websocketpp): Bump cmake minimum version as older versions will b…
TwentyPast4 Oct 24, 2024
259b5a7
feat(websockets): Add utility function to append resource to URI (NOJ…
TwentyPast4 Jan 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 51 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,57 @@
############ 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)

cmake_minimum_required (VERSION 3.5)
project(websocketpp VERSION 0.9.0)
############ 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)
set (WEBSOCKETPP_ENCODING_LIBS "")
set (WEBSOCKETPP_ENCODING_DEFS "")

# Include our cmake macros
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include (CMakeHelpers)

############ Encoding/decoding support

set(WEBSOCKETPP_WITH_GZIP FALSE CACHE BOOL "If true, build support for LZ77 compression. No requirements - added to code via https://github.com/ivan-tkatchev/yalz77.")
set(WEBSOCKETPP_WITH_DEFLATE FALSE CACHE BOOL "If true, build support for deflate compression. Requires zlib.")
if (WEBSOCKETPP_WITH_GZIP OR WEBSOCKETPP_WITH_DEFLATE)
find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
list(APPEND WEBSOCKETPP_ENCODING_LIBS ${ZLIB_LIBRARIES})
list(APPEND WEBSOCKETPP_INCLUDE ${ZLIB_INCLUDE_DIRS})
if (WEBSOCKETPP_WITH_DEFLATE)
list(APPEND WEBSOCKETPP_ENCODING_DEFS WEBSOCKETPP_WITH_DEFLATE=1)
endif ()
if (WEBSOCKETPP_WITH_GZIP)
list(APPEND WEBSOCKETPP_ENCODING_DEFS WEBSOCKETPP_WITH_GZIP=1)
endif ()
endif ()
endif ()

set(WEBSOCKETPP_WITH_BROTLI FALSE CACHE BOOL "If true, build support for brotli compression. Requires brotli.")
if (WEBSOCKETPP_WITH_BROTLI)
find_package(Brotli REQUIRED)
if (BROTLI_FOUND)
list(APPEND WEBSOCKETPP_ENCODING_LIBS ${BROTLI_LIBRARIES})
list(APPEND WEBSOCKETPP_INCLUDE ${BROTLI_INCLUDE_DIRS})
list(APPEND WEBSOCKETPP_ENCODING_DEFS WEBSOCKETPP_WITH_BROTLI=1)
endif ()
endif ()

set(WEBSOCKETPP_WITH_ZSTD FALSE CACHE BOOL "If true, build support for zstd compression. Requires zstd.")
if (WEBSOCKETPP_WITH_ZSTD)
find_package(zstd REQUIRED)
if (ZSTD_FOUND)
list(APPEND WEBSOCKETPP_ENCODING_LIBS ${ZSTD_LIBRARIES})
list(APPEND WEBSOCKETPP_INCLUDE ${ZSTD_INCLUDE_DIRS})
list(APPEND WEBSOCKETPP_ENCODING_DEFS WEBSOCKETPP_WITH_ZSTD=1)
endif ()
endif ()

# 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.
Expand All @@ -21,22 +63,6 @@ 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 3)
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)

include(GNUInstallDirs)
Expand Down Expand Up @@ -66,10 +92,6 @@ 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

Expand Down Expand Up @@ -254,9 +276,6 @@ endif()

############ Add projects

# Add main library
add_subdirectory (websocketpp)

# Add examples
if (BUILD_EXAMPLES)
include_subdirs ("examples")
Expand All @@ -269,8 +288,6 @@ 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"
Expand All @@ -288,3 +305,8 @@ install (FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-configVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)

add_library(websocketpp INTERFACE)
target_link_libraries(websocketpp INTERFACE ${WEBSOCKETPP_ENCODING_LIBS})
target_compile_definitions(websocketpp INTERFACE ${WEBSOCKETPP_ENCODING_DEFS})
target_include_directories(websocketpp INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

4 changes: 2 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ subprotocol_server = SConscript('#/examples/subprotocol_server/SConscript',varia
# 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)
# external_io_context
external_io_context = SConscript('#/examples/external_io_context/SConscript',variant_dir = builddir + 'external_io_context',duplicate = 0)

if not env['PLATFORM'].startswith('win'):
# iostream_server
Expand Down
14 changes: 7 additions & 7 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ in the installer and test system.
- 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 an example demonstrating the use of external `io_context`
- 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
Expand All @@ -232,7 +232,7 @@ in the installer and test system.
- 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
This feature caused memory leaks when the `io_context` 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.
Expand Down Expand Up @@ -315,7 +315,7 @@ in the installer and test system.
- 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`.
for exceptions to bubble out of transport methods like `io_context::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
Expand Down Expand Up @@ -385,7 +385,7 @@ in the installer and test system.

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
These may be used to replace manually managed `asio::io_context::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.
Expand Down Expand Up @@ -427,7 +427,7 @@ in the installer and test system.
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: Fix handler allocation crash with multithreaded `io_context`.
- 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
Expand Down Expand Up @@ -457,7 +457,7 @@ in the installer and test system.
- 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
- Re-introduces strands to asio transport, allowing `io_context` 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
Expand All @@ -482,7 +482,7 @@ in the installer and test system.
- 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
- Wrap internal `io_context` `run_one()` method
- Suppress error when trying to shut down a connection that was already closed

0.3.0-alpha3 - 2013-07-16
Expand Down
10 changes: 5 additions & 5 deletions cmake/CMakeHelpers.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

# Print build configuration
macro (print_used_build_config)
message ("\n=========== Used Build Configuration =============\n")
message (STATUS "=========== Websocketpp Build Configuration =============")
message (STATUS "ENABLE_CPP11 = " ${ENABLE_CPP11})
message (STATUS "BUILD_EXAMPLES = " ${BUILD_EXAMPLES})
message (STATUS "BUILD_TESTS = " ${BUILD_TESTS})
message ("")
message (STATUS "")
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 "")
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 "")
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 ("")
message (STATUS "===========================================================")
endmacro ()

# Adds the given folder_name into the source files of the current project.
Expand Down
45 changes: 45 additions & 0 deletions cmake/FindBrotli.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <[email protected]>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
include(FindPackageHandleStandardArgs)

find_path(BROTLI_INCLUDE_DIR "brotli/decode.h")

find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
find_library(BROTLIENC_LIBRARY NAMES brotlienc)

find_package_handle_standard_args(Brotli
FOUND_VAR
BROTLI_FOUND
REQUIRED_VARS
BROTLIDEC_LIBRARY
BROTLIENC_LIBRARY
BROTLICOMMON_LIBRARY
BROTLI_INCLUDE_DIR
FAIL_MESSAGE
"Could NOT find Brotli"
)

set(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR})
set(BROTLI_LIBRARIES ${BROTLICOMMON_LIBRARY} ${BROTLIDEC_LIBRARY} ${BROTLIENC_LIBRARY})
29 changes: 29 additions & 0 deletions cmake/Findzstd.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# - Find zstd
# Find the zstd compression library and includes
#
# ZSTD_INCLUDE_DIRS - where to find zstd.h, etc.
# ZSTD_LIBRARIES - List of libraries when using zstd.
# ZSTD_FOUND - True if zstd found.

find_path(ZSTD_INCLUDE_DIRS
NAMES zstd.h
HINTS ${zstd_ROOT_DIR}/include)

find_library(ZSTD_LIBRARIES
NAMES zstd
HINTS ${zstd_ROOT_DIR}/lib)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(zstd DEFAULT_MSG ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS)

mark_as_advanced(
ZSTD_LIBRARIES
ZSTD_INCLUDE_DIRS)

if(ZSTD_FOUND AND NOT (TARGET zstd::zstd))
add_library (zstd::zstd UNKNOWN IMPORTED)
set_target_properties(zstd::zstd
PROPERTIES
IMPORTED_LOCATION ${ZSTD_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${ZSTD_INCLUDE_DIRS})
endif()
12 changes: 6 additions & 6 deletions docs/faq.dox
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ Note: some browsers will allow the connection to continue if they requested a su

### 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:
The Asio transport based clients and servers use the Asio library's underlying `io_context` to handle asyncronous networking operations. The standard behavior of the io_context 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.
- 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_context gets around to asyncronously processing the socket and WebSocket protocol closing handshakes. The `io_context::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.
__WARNING__: Asio's `io_context` 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_context::stop` or `endpoint::stop` without a very good reason your program is likely broken and may exhibit erratic behavior. Specifically, `io_context::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.
- If your client uses the `start_perpetual` method it will prevent the io_context 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_context and/or are placing non-WebSocket++ operations on the `io_context` those operations may keep the `io_context` open even after all WebSocket++ operations have completed.
- If you are using `poll`/`poll_one`/`run_one` or otherwise manually driving the `io_context` 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_context::work`" cases.

### Is there a way to check the validity of a `connection_hdl`?

Expand Down
6 changes: 3 additions & 3 deletions docs/simple_broadcast_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class broadcast_server {
m_server.set_message_handler(bind(&broadcast_server::on_message,this,::_1,::_2));
}

void on_open(connection_hdl hdl) {
void on_open(connection_hdl_ref hdl) {
m_connections.insert(hdl);
}

void on_close(connection_hdl hdl) {
void on_close(connection_hdl_ref hdl) {
m_connections.erase(hdl);
}

void on_message(connection_hdl hdl, server::message_ptr msg) {
void on_message(connection_hdl_ref hdl, server::message_ptr msg) {
for (auto it : m_connections) {
m_server.send(it,msg);
}
Expand Down
4 changes: 2 additions & 2 deletions docs/simple_count_server_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class count_server {
m_server.set_close_handler(bind(&count_server::on_close,this,_1));
}

void on_open(connection_hdl hdl) {
void on_open(connection_hdl_ref hdl) {
std::lock_guard<std::mutex> lock(m_mutex);
m_connections.insert(hdl);
}

void on_close(connection_hdl hdl) {
void on_close(connection_hdl_ref hdl) {
std::lock_guard<std::mutex> lock(m_mutex);
m_connections.erase(hdl);
}
Expand Down
Loading