Changes for Beast version 59

This commit is contained in:
Vinnie Falco
2017-06-12 01:03:19 -07:00
committed by Miguel Portilla
parent 49bdf2e72d
commit 61316c7f95
36 changed files with 367 additions and 366 deletions

View File

@@ -23,7 +23,7 @@
#include <ripple/protocol/JsonFields.h>
#include <ripple/server/Port.h>
#include <beast/http/message.hpp>
#include <beast/http/streambuf_body.hpp>
#include <beast/http/dynamic_body.hpp>
#include <beast/http/string_body.hpp>
#include <beast/http/read.hpp>
#include <beast/http/write.hpp>
@@ -74,8 +74,8 @@ class JSONRPCClient : public AbstractClient
boost::asio::ip::tcp::endpoint ep_;
boost::asio::io_service ios_;
boost::asio::ip::tcp::socket stream_;
beast::streambuf bin_;
beast::streambuf bout_;
beast::multi_buffer bin_;
beast::multi_buffer bout_;
unsigned rpc_version_;
public:
@@ -109,12 +109,11 @@ public:
using namespace std::string_literals;
request<string_body> req;
req.method = "POST";
req.url = "/";
req.method(beast::http::verb::post);
req.target("/");
req.version = 11;
req.fields.insert("Content-Type", "application/json; charset=UTF-8");
req.fields.insert("Host",
ep_.address().to_string() + ":" + std::to_string(ep_.port()));
req.insert("Content-Type", "application/json; charset=UTF-8");
req.insert("Host", ep_);
{
Json::Value jr;
jr[jss::method] = cmd;
@@ -131,10 +130,10 @@ public:
}
req.body = to_string(jr);
}
prepare(req);
req.prepare();
write(stream_, req);
response<streambuf_body> res;
response<dynamic_body> res;
read(stream_, bin_, res);
Json::Reader jr;

View File

@@ -24,8 +24,7 @@
#include <ripple/json/to_string.h>
#include <ripple/protocol/JsonFields.h>
#include <ripple/server/Port.h>
#include <beast/core/placeholders.hpp>
#include <beast/core/streambuf.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/websocket.hpp>
#include <condition_variable>
@@ -95,8 +94,7 @@ class WSClientImpl : public WSClient
std::thread thread_;
boost::asio::ip::tcp::socket stream_;
beast::websocket::stream<boost::asio::ip::tcp::socket&> ws_;
beast::websocket::opcode op_;
beast::streambuf rb_;
beast::multi_buffer rb_;
bool peerClosed_ = false;
@@ -139,9 +137,9 @@ public:
stream_.connect(ep);
ws_.handshake(ep.address().to_string() +
":" + std::to_string(ep.port()), "/");
ws_.async_read(op_, rb_,
ws_.async_read(rb_,
strand_.wrap(std::bind(&WSClientImpl::on_read_msg,
this, beast::asio::placeholders::error)));
this, std::placeholders::_1)));
}
catch(std::exception&)
{
@@ -278,9 +276,9 @@ private:
msgs_.push_front(m);
cv_.notify_all();
}
ws_.async_read(op_, rb_, strand_.wrap(
ws_.async_read(rb_, strand_.wrap(
std::bind(&WSClientImpl::on_read_msg,
this, beast::asio::placeholders::error)));
this, std::placeholders::_1)));
}
// Called when the read op terminates