mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
RPCHandlers are pretty light objects and this allows us to pass in parameters like the InfoSub object without locking or adding more parameters to the RPC methods.
66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
#ifndef __RPCSERVER__
|
|
#define __RPCSERVER__
|
|
|
|
#include <boost/array.hpp>
|
|
#include <boost/shared_ptr.hpp>
|
|
#include <boost/enable_shared_from_this.hpp>
|
|
#include <boost/asio.hpp>
|
|
|
|
#include "../json/value.h"
|
|
|
|
#include "HTTPRequest.h"
|
|
#include "RippleAddress.h"
|
|
#include "NetworkOPs.h"
|
|
#include "SerializedLedger.h"
|
|
#include "RPCHandler.h"
|
|
|
|
class RPCServer : public boost::enable_shared_from_this<RPCServer>
|
|
{
|
|
public:
|
|
|
|
typedef boost::shared_ptr<RPCServer> pointer;
|
|
|
|
private:
|
|
|
|
NetworkOPs* mNetOps;
|
|
|
|
boost::asio::ip::tcp::socket mSocket;
|
|
|
|
boost::asio::streambuf mLineBuffer;
|
|
std::vector<unsigned char> mQueryVec;
|
|
std::string mReplyStr;
|
|
|
|
HTTPRequest mHTTPRequest;
|
|
|
|
|
|
int mRole;
|
|
|
|
RPCServer(boost::asio::io_service& io_service, NetworkOPs* nopNetwork);
|
|
|
|
RPCServer(const RPCServer&); // no implementation
|
|
RPCServer& operator=(const RPCServer&); // no implementation
|
|
|
|
void handle_write(const boost::system::error_code& ec);
|
|
void handle_read_line(const boost::system::error_code& ec);
|
|
void handle_read_req(const boost::system::error_code& ec);
|
|
|
|
std::string handleRequest(const std::string& requestStr);
|
|
|
|
public:
|
|
static pointer create(boost::asio::io_service& io_service, NetworkOPs* mNetOps)
|
|
{
|
|
return pointer(new RPCServer(io_service, mNetOps));
|
|
}
|
|
|
|
boost::asio::ip::tcp::socket& getSocket()
|
|
{
|
|
return mSocket;
|
|
}
|
|
|
|
void connected();
|
|
};
|
|
|
|
#endif
|
|
|
|
// vim:ts=4
|