Remove opcode from read, async_read (API Change):

fix #446

* Read signatures no longer include `opcode`

* stream::got_binary and stream::got_text inform the caller if
  the current incoming message is binary or text.

Actions Required:

* Remove the `opcode` reference parameter from calls to synchronous
  and asynchronous read functions, replace the logic with calls to
  stream::got_binary and stream::got_text instead.
This commit is contained in:
Vinnie Falco committed 2017-07-20 08:12:19 -07:00
1 parent 3d6574da81
commit 620ce08d6a
13 files changed
+142 -145

No files matched your search

-2
View File
@@ -42,8 +42,6 @@ int main()
// Receive Secure WebSocket message, print and close using Beast
beast::multi_buffer b;
beast::websocket::opcode op;
ws.read(op, b);
ws.close(beast::websocket::close_code::normal);
std::cout << beast::buffers(b.data()) << "\n";
}
+2 -3
View File
@@ -139,7 +139,6 @@ private:
int state = 0;
beast::websocket::stream<socket_type> ws;
boost::asio::io_service::strand strand;
beast::websocket::opcode op;
beast::multi_buffer db;
std::size_t id;
@@ -218,7 +217,7 @@ private:
d.db.consume(d.db.size());
// read message
d.state = 2;
d.ws.async_read(d.op, d.db,
d.ws.async_read(d.db,
d.strand.wrap(std::move(*this)));
return;
@@ -230,7 +229,7 @@ private:
return fail("async_read", ec);
// write message
d.state = 1;
d.ws.binary(d.op == beast::websocket::opcode::binary);
d.ws.binary(d.ws.got_binary());
d.ws.async_write(d.db.data(),
d.strand.wrap(std::move(*this)));
return;
+1 -2
View File
@@ -30,8 +30,7 @@ int main()
// Receive WebSocket message, print and close using beast
beast::multi_buffer b;
beast::websocket::opcode op;
ws.read(op, b);
ws.read(b);
ws.close(beast::websocket::close_code::normal);
std::cout << beast::buffers(b.data()) << "\n";
}
+2 -3
View File
@@ -207,15 +207,14 @@ private:
}
for(;;)
{
beast::websocket::opcode op;
beast::multi_buffer b;
ws.read(op, b, ec);
ws.read(b, ec);
if(ec)
{
auto const s = ec.message();
break;
}
ws.binary(op == beast::websocket::opcode::binary);
ws.binary(ws.got_binary());
ws.write(b.data(), ec);
if(ec)
break;