From 2ff5de97c78a92e7a1455f75171a307e994d385a Mon Sep 17 00:00:00 2001 From: Tian jianyong <11429339@qq.com> Date: Fri, 9 May 2025 14:51:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BA=A2=E7=BB=BF=E7=81=AF?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=EF=BC=8C=E4=BD=BF=E7=94=A8=20boost::asio::pl?= =?UTF-8?q?aceholders::error=20=E4=BB=A3=E6=9B=BF=20boost::bind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/network/TrafficLightHttpServer.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/network/TrafficLightHttpServer.cpp b/src/network/TrafficLightHttpServer.cpp index 97df169..1630fca 100644 --- a/src/network/TrafficLightHttpServer.cpp +++ b/src/network/TrafficLightHttpServer.cpp @@ -5,10 +5,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -103,12 +105,12 @@ namespace network { explicit TrafficLightSession(tcp::socket&& socket, std::string const& doc_root, net::io_context& ioc, System& system_ref) : socket_(std::move(socket)), doc_root_(doc_root), - strand_(net::make_strand(ioc.get_executor())), + strand_(ioc.get_executor()), ioc_(ioc), system_(system_ref) {} void run() { - net::dispatch(strand_, beast::bind_front_handler(&TrafficLightSession::do_read, shared_from_this())); + net::dispatch(strand_, boost::bind(&TrafficLightSession::do_read, shared_from_this())); } private: @@ -116,7 +118,9 @@ namespace network { req_ = {}; http::async_read(socket_, buffer_, req_, net::bind_executor(strand_, - beast::bind_front_handler(&TrafficLightSession::on_read, shared_from_this()) + boost::bind(&TrafficLightSession::on_read, shared_from_this(), + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred) )); } @@ -270,9 +274,11 @@ namespace network { void do_accept() { acceptor_.async_accept( net::bind_executor(acceptor_.get_executor(), - beast::bind_front_handler( - &TrafficLightListener::on_accept, - shared_from_this()))); + boost::bind(&TrafficLightListener::on_accept, shared_from_this(), + boost::asio::placeholders::error, + boost::placeholders::_2) + ) + ); } void on_accept(beast::error_code ec, tcp::socket socket) {