--- src/lib/util/server_ws_impl.hpp.orig 2020-10-27 02:11:42.000000000 -0700 +++ src/lib/util/server_ws_impl.hpp 2023-03-09 20:00:24.000000000 -0800 @@ -9,6 +9,14 @@ #include "asio.h" #include +// ### Newish asio API get_io_service is now MIA. ### +#define NEW_ASIO_API 1 +#ifdef NEW_ASIO_API +#define GET_IO_SERVICE(s) ((asio::io_context&)(s).get_executor().context()) +#else +#define GET_IO_SERVICE(s) ((s).get_io_service()) +#endif + #include "server_ws.hpp" #include #include @@ -74,10 +82,10 @@ public: virtual ~Connection() {} - explicit Connection(const std::shared_ptr &socket) : super(0), socket(socket), strand(socket->get_io_service()), closed(false) { } + explicit Connection(const std::shared_ptr &socket) : super(0), socket(socket), strand(GET_IO_SERVICE(*socket)), closed(false) { } private: - explicit Connection(socket_type *socket): super(0), socket(socket), strand(socket->get_io_service()), closed(false) { } + explicit Connection(socket_type *socket): super(0), socket(socket), strand(GET_IO_SERVICE(*socket)), closed(false) { } class SendData { public: @@ -361,7 +369,7 @@ std::shared_ptr get_timeout_timer(const std::shared_ptr &connection, size_t seconds) { if (seconds == 0) return nullptr; - auto timer = std::make_shared(connection->socket->get_io_service()); + auto timer = std::make_shared(GET_IO_SERVICE(*(connection->socket))); timer->expires_at(std::chrono::system_clock::now() + std::chrono::seconds(static_cast(seconds))); timer->async_wait([connection](const std::error_code& ec){ if(!ec) { @@ -652,7 +660,7 @@ void timer_idle_init(const std::shared_ptr &connection) { if(config.timeout_idle>0) { - connection->timer_idle= std::make_unique(connection->socket->get_io_service()); + connection->timer_idle= std::make_unique(GET_IO_SERVICE(*(connection->socket))); connection->timer_idle->expires_from_now(std::chrono::seconds(static_cast(config.timeout_idle))); timer_idle_expired_function(connection); }