mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Convert code to use boost::beast
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/protocol/JsonFields.h>
|
||||
#include <ripple/server/Port.h>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/websocket.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
|
||||
#include <condition_variable>
|
||||
|
||||
@@ -92,8 +92,8 @@ class WSClientImpl : public WSClient
|
||||
boost::asio::io_service::strand strand_;
|
||||
std::thread thread_;
|
||||
boost::asio::ip::tcp::socket stream_;
|
||||
beast::websocket::stream<boost::asio::ip::tcp::socket&> ws_;
|
||||
beast::multi_buffer rb_;
|
||||
boost::beast::websocket::stream<boost::asio::ip::tcp::socket&> ws_;
|
||||
boost::beast::multi_buffer rb_;
|
||||
|
||||
bool peerClosed_ = false;
|
||||
|
||||
@@ -109,13 +109,17 @@ class WSClientImpl : public WSClient
|
||||
|
||||
unsigned rpc_version_;
|
||||
|
||||
void cleanup()
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
ios_.post(strand_.wrap([this] {
|
||||
error_code ec;
|
||||
if (!peerClosed_)
|
||||
ws_.close({}, ec);
|
||||
stream_.close(ec);
|
||||
{
|
||||
ws_.async_close({}, strand_.wrap([&](error_code ec) {
|
||||
stream_.cancel(ec);
|
||||
}));
|
||||
}
|
||||
}));
|
||||
work_ = boost::none;
|
||||
thread_.join();
|
||||
@@ -173,7 +177,7 @@ public:
|
||||
else
|
||||
jp[jss::command] = cmd;
|
||||
auto const s = to_string(jp);
|
||||
ws_.write_frame(true, buffer(s));
|
||||
ws_.write_some(true, buffer(s));
|
||||
}
|
||||
|
||||
auto jv = findMsg(5s,
|
||||
@@ -259,7 +263,7 @@ private:
|
||||
{
|
||||
if(ec)
|
||||
{
|
||||
if(ec == beast::websocket::error::closed)
|
||||
if(ec == boost::beast::websocket::error::closed)
|
||||
peerClosed_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user