Skip to content

Commit

Permalink
Improve proxy_socket class, remove BOOST_ASIO_INITFN_RESULT_TYPE and …
Browse files Browse the repository at this point in the history
…BOOST_ASIO_MOVE_ARG
  • Loading branch information
Jackarain committed Feb 3, 2024
1 parent 5a9ed5e commit 7fd7a49
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions proxy/include/proxy/proxy_socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,38 +204,30 @@ namespace util {
}

template <typename ConnectHandler>
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<ConnectHandler>(handler));
}

template <typename MutableBufferSequence, typename ReadHandler>
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<ReadHandler,
void (boost::system::error_code, std::size_t)>(
initiate_async_read_some(this), handler, buffers);
}

template <typename ConstBufferSequence, typename WriteHandler>
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<WriteHandler,
void (boost::system::error_code, std::size_t)>(
initiate_async_write_some(this), handler, buffers);
}

template <typename WaitHandler>
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<WaitHandler>(handler));
}
Expand All @@ -257,7 +249,7 @@ namespace util {
}

template <typename ReadHandler, typename MutableBufferSequence>
void operator()(BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
void operator()(ReadHandler&& handler,
const MutableBufferSequence& buffers) const
{
// 读取数据后, 调用 unscramble_ 立即解密数据.
Expand Down Expand Up @@ -301,7 +293,7 @@ namespace util {
}

template <typename WriteHandler, typename ConstBufferSequence>
void operator()(BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
void operator()(WriteHandler&& handler,
const ConstBufferSequence& buffers) const
{
// 发送数据前, 立即调用 scramble_ 加密数据.
Expand Down

0 comments on commit 7fd7a49

Please sign in to comment.