From 4c57860d7ec5e2c25d973256be41948554bfa873 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 26 Aug 2020 11:18:12 +0200 Subject: [PATCH] Fixed compilation issue with standalone Asio: https://gitlab.com/eidheim/Simple-WebSocket-Server/-/issues/151 --- asio_compatibility.hpp | 6 +++--- client_http.hpp | 2 +- server_http.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/asio_compatibility.hpp b/asio_compatibility.hpp index a9abd7c..3d2df07 100644 --- a/asio_compatibility.hpp +++ b/asio_compatibility.hpp @@ -42,9 +42,9 @@ namespace SimpleWeb { inline asio::ip::address make_address(const std::string &str) noexcept { return asio::ip::make_address(str); } - template - asio::executor get_socket_executor(socket_type &socket) { - return socket.get_executor(); + template + asio::steady_timer make_steady_timer(socket_type &socket, std::chrono::duration duration) { + return asio::steady_timer(socket.get_executor(), duration); } template void async_resolve(asio::ip::tcp::resolver &resolver, const std::pair &host_port, handler_type &&handler) { diff --git a/client_http.hpp b/client_http.hpp index ae0a215..0b6b866 100644 --- a/client_http.hpp +++ b/client_http.hpp @@ -173,7 +173,7 @@ namespace SimpleWeb { timer = nullptr; return; } - timer = std::unique_ptr(new asio::steady_timer(get_socket_executor(*socket), std::chrono::seconds(seconds))); + timer = std::unique_ptr(new asio::steady_timer(make_steady_timer(*socket, std::chrono::seconds(seconds)))); std::weak_ptr self_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed timer->async_wait([self_weak](const error_code &ec) { if(!ec) { diff --git a/server_http.hpp b/server_http.hpp index 4506313..698fb43 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -303,7 +303,7 @@ namespace SimpleWeb { return; } - timer = std::unique_ptr(new asio::steady_timer(get_socket_executor(*socket), std::chrono::seconds(seconds))); + timer = std::unique_ptr(new asio::steady_timer(make_steady_timer(*socket, std::chrono::seconds(seconds)))); std::weak_ptr self_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed timer->async_wait([self_weak](const error_code &ec) { if(!ec) {