Skip to content

Commit

Permalink
Revert "[REMOVE] remove async_handshake return values"
Browse files Browse the repository at this point in the history
This reverts commit 90fc956.
  • Loading branch information
vinniefalco committed Apr 27, 2017
1 parent 90fc956 commit a3d0afa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
12 changes: 7 additions & 5 deletions include/beast/websocket/impl/handshake.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ operator()(error_code ec, bool again)
}
}
}
d_.invoke(ec);
// args to invoke must be on the stack
auto const res = std::move(d.res);
d_.invoke(ec, res);
}

template<class NextLayer>
template<class HandshakeHandler>
typename async_completion<HandshakeHandler,
void(error_code)>::result_type
void(error_code, response_type)>::result_type
stream<NextLayer>::
async_handshake(boost::string_ref const& host,
boost::string_ref const& resource,
Expand All @@ -166,7 +168,7 @@ async_handshake(boost::string_ref const& host,
static_assert(is_AsyncStream<next_layer_type>::value,
"AsyncStream requirements not met");
beast::async_completion<HandshakeHandler,
void(error_code)> completion{handler};
void(error_code, response_type)> completion{handler};
handshake_op<decltype(completion.handler)>{
completion.handler, *this, host, resource,
&default_decorate_req};
Expand All @@ -176,7 +178,7 @@ async_handshake(boost::string_ref const& host,
template<class NextLayer>
template<class RequestDecorator, class HandshakeHandler>
typename async_completion<HandshakeHandler,
void(error_code)>::result_type
void(error_code, response_type)>::result_type
stream<NextLayer>::
async_handshake_ex(boost::string_ref const& host,
boost::string_ref const& resource,
Expand All @@ -189,7 +191,7 @@ async_handshake_ex(boost::string_ref const& host,
RequestDecorator>::value,
"RequestDecorator requirements not met");
beast::async_completion<HandshakeHandler,
void(error_code)> completion{handler};
void(error_code, response_type)> completion{handler};
handshake_op<decltype(completion.handler)>{
completion.handler, *this, host, resource,
decorator};
Expand Down
4 changes: 2 additions & 2 deletions include/beast/websocket/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ class stream : public detail::stream_base
void_or_deduced
#else
typename async_completion<HandshakeHandler,
void(error_code)>::result_type
void(error_code, response_type)>::result_type
#endif
async_handshake(boost::string_ref const& host,
boost::string_ref const& resource,
Expand Down Expand Up @@ -1757,7 +1757,7 @@ class stream : public detail::stream_base
void_or_deduced
#else
typename async_completion<HandshakeHandler,
void(error_code)>::result_type
void(error_code, response_type)>::result_type
#endif
async_handshake_ex(boost::string_ref const& host,
boost::string_ref const& resource,
Expand Down
10 changes: 6 additions & 4 deletions test/websocket/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,30 +377,32 @@ class stream_test
}

template<class NextLayer>
void
response_type
handshake(stream<NextLayer>& ws,
boost::string_ref const& uri,
boost::string_ref const& path) const
{
error_code ec;
ws.async_handshake(
auto res = ws.async_handshake(
uri, path, yield_[ec]);
if(ec)
throw system_error{ec};
return res;
}

template<class NextLayer, class Decorator>
void
response_type
handshake_ex(stream<NextLayer>& ws,
boost::string_ref const& uri,
boost::string_ref const& path,
Decorator const &d) const
{
error_code ec;
ws.async_handshake_ex(
auto res = ws.async_handshake_ex(
uri, path, d, yield_[ec]);
if(ec)
throw system_error{ec};
return res;
}

template<class NextLayer>
Expand Down

0 comments on commit a3d0afa

Please sign in to comment.