From 7fd7a49aeb34a9f522aea79324a95503a882022c Mon Sep 17 00:00:00 2001 From: Jackarain Date: Sat, 3 Feb 2024 21:42:55 +0800 Subject: [PATCH] Improve proxy_socket class, remove BOOST_ASIO_INITFN_RESULT_TYPE and BOOST_ASIO_MOVE_ARG --- proxy/include/proxy/proxy_socket.hpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/proxy/include/proxy/proxy_socket.hpp b/proxy/include/proxy/proxy_socket.hpp index fcd7caf6ef..e5751ffd85 100644 --- a/proxy/include/proxy/proxy_socket.hpp +++ b/proxy/include/proxy/proxy_socket.hpp @@ -204,18 +204,14 @@ namespace util { } template - BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler, - void(boost::system::error_code)) - async_connect(const tcp::endpoint& endpoint, ConnectHandler&& handler) + auto async_connect(const tcp::endpoint& endpoint, ConnectHandler&& handler) { return next_layer_.async_connect(endpoint, std::forward(handler)); } template - BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, - void(boost::system::error_code, std::size_t)) - async_read_some(const MutableBufferSequence& buffers, ReadHandler&& handler) + auto async_read_some(const MutableBufferSequence& buffers, ReadHandler&& handler) { return net::async_initiate( @@ -223,9 +219,7 @@ namespace util { } template - BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, - void(boost::system::error_code, std::size_t)) - async_write_some(const ConstBufferSequence& buffers, WriteHandler&& handler) + auto async_write_some(const ConstBufferSequence& buffers, WriteHandler&& handler) { return net::async_initiate( @@ -233,9 +227,7 @@ namespace util { } template - BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler, - void(boost::system::error_code)) - async_wait(net::socket_base::wait_type w, WaitHandler&& handler) + auto async_wait(net::socket_base::wait_type w, WaitHandler&& handler) { return next_layer_.async_wait(w, std::forward(handler)); } @@ -257,7 +249,7 @@ namespace util { } template - void operator()(BOOST_ASIO_MOVE_ARG(ReadHandler) handler, + void operator()(ReadHandler&& handler, const MutableBufferSequence& buffers) const { // 读取数据后, 调用 unscramble_ 立即解密数据. @@ -301,7 +293,7 @@ namespace util { } template - void operator()(BOOST_ASIO_MOVE_ARG(WriteHandler) handler, + void operator()(WriteHandler&& handler, const ConstBufferSequence& buffers) const { // 发送数据前, 立即调用 scramble_ 加密数据.