xrpld
Loading...
Searching...
No Matches
xrpl::test::JSONRPCClient Class Reference
Inheritance diagram for xrpl::test::JSONRPCClient:
Collaboration diagram for xrpl::test::JSONRPCClient:

Public Member Functions

 JSONRPCClient (Config const &cfg, unsigned rpcVersion)
json::Value invoke (std::string const &cmd, json::Value const &params) override
 Submit a command synchronously.
unsigned version () const override
 Get RPC 1.0 or RPC 2.0.
void disconnect () override
 Close the client's connection to the server.

Private Member Functions

void reconnect ()

Static Private Member Functions

static boost::asio::ip::tcp::endpoint getEndpoint (BasicConfig const &cfg)
template<class ConstBufferSequence>
static std::string bufferString (ConstBufferSequence const &b)
static bool droppedConnection (boost::system::error_code const &ec)

Private Attributes

boost::asio::ip::tcp::endpoint ep_
boost::asio::io_context ios_
boost::asio::ip::tcp::socket stream_
boost::beast::multi_buffer bin_
boost::beast::multi_buffer bout_
unsigned rpcVersion_
bool disconnected_ = false

Detailed Description

Definition at line 42 of file JSONRPCClient.cpp.

Constructor & Destructor Documentation

◆ JSONRPCClient()

xrpl::test::JSONRPCClient::JSONRPCClient ( Config const & cfg,
unsigned rpcVersion )
explicit

Definition at line 127 of file JSONRPCClient.cpp.

Member Function Documentation

◆ getEndpoint()

boost::asio::ip::tcp::endpoint xrpl::test::JSONRPCClient::getEndpoint ( BasicConfig const & cfg)
staticprivate

Definition at line 45 of file JSONRPCClient.cpp.

◆ bufferString()

template<class ConstBufferSequence>
std::string xrpl::test::JSONRPCClient::bufferString ( ConstBufferSequence const & b)
staticprivate

Definition at line 76 of file JSONRPCClient.cpp.

◆ droppedConnection()

bool xrpl::test::JSONRPCClient::droppedConnection ( boost::system::error_code const & ec)
staticprivate

Definition at line 98 of file JSONRPCClient.cpp.

◆ reconnect()

void xrpl::test::JSONRPCClient::reconnect ( )
private

Definition at line 118 of file JSONRPCClient.cpp.

◆ invoke()

json::Value xrpl::test::JSONRPCClient::invoke ( std::string const & cmd,
json::Value const & params )
overridevirtual

Submit a command synchronously.

The arguments to the function and the returned JSON are in a normalized format, the same whether the client is using the JSON-RPC over HTTP/S or WebSocket transport.

Parameters
cmdThe command to execute
paramsjson::Value of null or object type with zero or more key/value pairs.
Returns
The server response in normalized format.

Implements xrpl::test::AbstractClient.

Definition at line 138 of file JSONRPCClient.cpp.

◆ version()

unsigned xrpl::test::JSONRPCClient::version ( ) const
nodiscardoverridevirtual

Get RPC 1.0 or RPC 2.0.

Implements xrpl::test::AbstractClient.

Definition at line 213 of file JSONRPCClient.cpp.

◆ disconnect()

void xrpl::test::JSONRPCClient::disconnect ( )
overridevirtual

Close the client's connection to the server.

Releases the connection the client holds against the server's per-port connection limit. After this call the client must not be used to invoke() again. Tests use this to deterministically free the slot rather than waiting for the server's idle timeout to drop it.

Implements xrpl::test::AbstractClient.

Definition at line 219 of file JSONRPCClient.cpp.

Member Data Documentation

◆ ep_

boost::asio::ip::tcp::endpoint xrpl::test::JSONRPCClient::ep_
private

Definition at line 85 of file JSONRPCClient.cpp.

◆ ios_

boost::asio::io_context xrpl::test::JSONRPCClient::ios_
private

Definition at line 86 of file JSONRPCClient.cpp.

◆ stream_

boost::asio::ip::tcp::socket xrpl::test::JSONRPCClient::stream_
private

Definition at line 87 of file JSONRPCClient.cpp.

◆ bin_

boost::beast::multi_buffer xrpl::test::JSONRPCClient::bin_
private

Definition at line 88 of file JSONRPCClient.cpp.

◆ bout_

boost::beast::multi_buffer xrpl::test::JSONRPCClient::bout_
private

Definition at line 89 of file JSONRPCClient.cpp.

◆ rpcVersion_

unsigned xrpl::test::JSONRPCClient::rpcVersion_
private

Definition at line 90 of file JSONRPCClient.cpp.

◆ disconnected_

bool xrpl::test::JSONRPCClient::disconnected_ = false
private

Definition at line 92 of file JSONRPCClient.cpp.