Use correct handler signature in fail_op

fix #716
This commit is contained in:
Vinnie Falco
2017-08-03 04:21:24 -07:00
parent 1f0ad880fc
commit e5e25f5c17
3 changed files with 37 additions and 2 deletions

View File

@ -1,6 +1,7 @@
Version 99: Version 99:
* Log the value of LIB_DIR for doc builds (debug) * Log the value of LIB_DIR for doc builds (debug)
* Use correct handler signature in fail_op
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -225,9 +225,9 @@ operator()(error_code ec, std::size_t)
ws_.wr_op_.maybe_invoke(); ws_.wr_op_.maybe_invoke();
if(! dispatched_) if(! dispatched_)
ws_.stream_.get_io_service().post( ws_.stream_.get_io_service().post(
bind_handler(std::move(h_), ec)); bind_handler(std::move(h_), ec, 0));
else else
h_(ec); h_(ec, 0);
} }
} // websocket } // websocket

View File

@ -277,6 +277,15 @@ public:
return ws.read(buffer); return ws.read(buffer);
} }
template<
class NextLayer, class MutableBufferSequence>
std::size_t
read_some(stream<NextLayer>& ws,
MutableBufferSequence const& buffers) const
{
return ws.read_some(buffers);
}
template< template<
class NextLayer, class ConstBufferSequence> class NextLayer, class ConstBufferSequence>
void void
@ -518,6 +527,20 @@ public:
return bytes_written; return bytes_written;
} }
template<
class NextLayer, class MutableBufferSequence>
std::size_t
read_some(stream<NextLayer>& ws,
MutableBufferSequence const& buffers) const
{
error_code ec;
auto const bytes_written =
ws.async_read_some(buffers, yield_[ec]);
if(ec)
throw system_error{ec};
return bytes_written;
}
template< template<
class NextLayer, class ConstBufferSequence> class NextLayer, class ConstBufferSequence>
void void
@ -1674,6 +1697,17 @@ public:
bool once; bool once;
// read_some
{
c.write(ws, sbuf("Hello"));
char buf[10];
auto const bytes_written =
c.read_some(ws, buffer(buf, sizeof(buf)));
BEAST_EXPECT(bytes_written == 5);
buf[5] = 0;
BEAST_EXPECT(string_view(buf) == "Hello");
}
// send ping and message // send ping and message
{ {
once = false; once = false;