blob: edfc15b97248e01b6950975ee035b988e2eae7fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#ifndef RPC_SERVER
#define RPC_SERVER
#include <map>
#include <string>
#include <rapidjson/document.h>
#include "http_server.h"
class RPCRequest {
private:
HTTPRequest* request;
rapidjson::Document body;
rapidjson::Value id;
std::string method;
rapidjson::Value params;
void response(rapidjson::Value& result);
public:
RPCRequest(HTTPRequest* request);
~RPCRequest();
rapidjson::MemoryPoolAllocator<>& get_allocator() { return this->body.GetAllocator(); };
std::string get_method() { return this->method; }
rapidjson::Value& get_params() { return this->params; }
void result(rapidjson::Value result);
void error(rapidjson::Value error);
void close();
};
class RPCServer {
private:
HTTPServer http_server;
public:
RPCServer(unsigned long addr, unsigned short port);
HTTPServer& get_http_server() { return this->http_server; }
RPCRequest* receive_request();
};
#endif
|