From 631359213a04a7038313691b7c09fa8e8bfaed49 Mon Sep 17 00:00:00 2001 From: "sariru@gmail.com" <89619301+itsafuu@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:53:55 -0400 Subject: [PATCH] Boost 1.85 required changes [ci skip] --- build/CommonBuildParameters.cmake | 2 +- src/api/transport/impl/ws/ws_session.cpp | 53 ++++++++++++++---------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/build/CommonBuildParameters.cmake b/build/CommonBuildParameters.cmake index 19a549db..a96c1ffd 100644 --- a/build/CommonBuildParameters.cmake +++ b/build/CommonBuildParameters.cmake @@ -1,6 +1,6 @@ # BOOST VERSION TO USE set(BOOST_MAJOR_VERSION "1" CACHE STRING "Boost Major Version") -set(BOOST_MINOR_VERSION "80" CACHE STRING "Boost Minor Version") +set(BOOST_MINOR_VERSION "85" CACHE STRING "Boost Minor Version") set(BOOST_PATCH_VERSION "0" CACHE STRING "Boost Patch Version") # convenience settings diff --git a/src/api/transport/impl/ws/ws_session.cpp b/src/api/transport/impl/ws/ws_session.cpp index 5f3c346b..021240ae 100644 --- a/src/api/transport/impl/ws/ws_session.cpp +++ b/src/api/transport/impl/ws/ws_session.cpp @@ -17,9 +17,10 @@ namespace sgns::api { id_(id) {} void WsSession::start() { - boost::asio::dispatch(stream_.get_executor(), - boost::beast::bind_front_handler(&WsSession::onRun, - shared_from_this())); + boost::asio::dispatch(stream_.get_executor(), + boost::asio::bind_executor(stream_.get_executor(), + std::bind(&WsSession::onRun, + shared_from_this()))); } void WsSession::stop() { @@ -34,15 +35,21 @@ namespace sgns::api { } void WsSession::asyncRead() { - stream_.async_read(rbuffer_, - boost::beast::bind_front_handler(&WsSession::onRead, - shared_from_this())); + stream_.async_read(rbuffer_, + boost::asio::bind_executor(stream_.get_executor(), + std::bind(&WsSession::onRead, + shared_from_this(), + std::placeholders::_1, + std::placeholders::_2))); } void WsSession::asyncWrite() { - stream_.async_write(wbuffer_.data(), - boost::beast::bind_front_handler(&WsSession::onWrite, - shared_from_this())); + stream_.async_write(wbuffer_.data(), + boost::asio::bind_executor(stream_.get_executor(), + std::bind(&WsSession::onWrite, + shared_from_this(), + std::placeholders::_1, + std::placeholders::_2))); } sgns::api::Session::SessionId WsSession::id() const { @@ -59,20 +66,22 @@ namespace sgns::api { } void WsSession::onRun() { - // Set suggested timeout settings for the websocket - stream_.set_option(boost::beast::websocket::stream_base::timeout::suggested( - boost::beast::role_type::server)); - - // Set a decorator to change the Server of the handshake - stream_.set_option(boost::beast::websocket::stream_base::decorator( - [](boost::beast::websocket::response_type &res) { - res.set(boost::beast::http::field::server, + // Set suggested timeout settings for the websocket + stream_.set_option(boost::beast::websocket::stream_base::timeout::suggested( + boost::beast::role_type::server)); + + // Set a decorator to change the Server of the handshake + stream_.set_option(boost::beast::websocket::stream_base::decorator( + [](boost::beast::websocket::response_type& res) { + res.set(boost::beast::http::field::server, std::string(BOOST_BEAST_VERSION_STRING) - + " websocket-server-async"); - })); - // Accept the websocket handshake - stream_.async_accept(boost::beast::bind_front_handler(&WsSession::onAccept, - shared_from_this())); + + " websocket-server-async"); + })); + // Accept the websocket handshake + stream_.async_accept(boost::asio::bind_executor(stream_.get_executor(), + std::bind(&WsSession::onAccept, + shared_from_this(), + std::placeholders::_1))); } void WsSession::onAccept(boost::system::error_code ec) {