Revert "Convert code to use boost::beast"

This reverts commit cc9c976b76.
This commit is contained in:
seelabs
2018-02-12 11:16:21 -05:00
parent 060692aad4
commit 9a210cfda5
72 changed files with 1104 additions and 471 deletions

View File

@@ -22,11 +22,11 @@
#include <ripple/json/to_string.h>
#include <ripple/protocol/JsonFields.h>
#include <ripple/server/Port.h>
#include <boost/beast/http/message.hpp>
#include <boost/beast/http/dynamic_body.hpp>
#include <boost/beast/http/string_body.hpp>
#include <boost/beast/http/read.hpp>
#include <boost/beast/http/write.hpp>
#include <beast/http/message.hpp>
#include <beast/http/dynamic_body.hpp>
#include <beast/http/string_body.hpp>
#include <beast/http/read.hpp>
#include <beast/http/write.hpp>
#include <boost/asio.hpp>
#include <string>
@@ -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_;
boost::beast::multi_buffer bin_;
boost::beast::multi_buffer bout_;
beast::multi_buffer bin_;
beast::multi_buffer bout_;
unsigned rpc_version_;
public:
@@ -104,14 +104,14 @@ public:
invoke(std::string const& cmd,
Json::Value const& params) override
{
using namespace boost::beast::http;
using namespace beast::http;
using namespace boost::asio;
using namespace std::string_literals;
request<string_body> req;
req.method(boost::beast::http::verb::post);
req.method(beast::http::verb::post);
req.target("/");
req.version(11);
req.version = 11;
req.insert("Content-Type", "application/json; charset=UTF-8");
req.insert("Host", ep_);
{
@@ -128,7 +128,7 @@ public:
Json::Value& ja = jr[jss::params] = Json::arrayValue;
ja.append(params);
}
req.body() = to_string(jr);
req.body = to_string(jr);
}
req.prepare_payload();
write(stream_, req);
@@ -138,7 +138,7 @@ public:
Json::Reader jr;
Json::Value jv;
jr.parse(buffer_string(res.body().data()), jv);
jr.parse(buffer_string(res.body.data()), jv);
if(jv["result"].isMember("error"))
jv["error"] = jv["result"]["error"];
if(jv["result"].isMember("status"))

View File

@@ -24,8 +24,8 @@
#include <ripple/json/to_string.h>
#include <ripple/protocol/JsonFields.h>
#include <ripple/server/Port.h>
#include <boost/beast/core/multi_buffer.hpp>
#include <boost/beast/websocket.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/websocket.hpp>
#include <condition_variable>
@@ -93,8 +93,8 @@ class WSClientImpl : public WSClient
boost::asio::io_service::strand strand_;
std::thread thread_;
boost::asio::ip::tcp::socket stream_;
boost::beast::websocket::stream<boost::asio::ip::tcp::socket&> ws_;
boost::beast::multi_buffer rb_;
beast::websocket::stream<boost::asio::ip::tcp::socket&> ws_;
beast::multi_buffer rb_;
bool peerClosed_ = false;
@@ -110,17 +110,13 @@ class WSClientImpl : public WSClient
unsigned rpc_version_;
void
cleanup()
void cleanup()
{
ios_.post(strand_.wrap([this] {
error_code ec;
if (!peerClosed_)
{
ws_.async_close({}, strand_.wrap([&](error_code ec) {
stream_.cancel(ec);
}));
}
ws_.close({}, ec);
stream_.close(ec);
}));
work_ = boost::none;
thread_.join();
@@ -178,7 +174,7 @@ public:
else
jp[jss::command] = cmd;
auto const s = to_string(jp);
ws_.write_some(true, buffer(s));
ws_.write_frame(true, buffer(s));
}
auto jv = findMsg(5s,
@@ -264,7 +260,7 @@ private:
{
if(ec)
{
if(ec == boost::beast::websocket::error::closed)
if(ec == beast::websocket::error::closed)
peerClosed_ = true;
return;
}