hdac SDK
SDK for hdac blockchain development
rpcclient.h
1 #ifndef RPCCLIENT_H
2 #define RPCCLIENT_H
3 
4 #include <string>
5 #include <json_spirit/json_spirit.h>
6 
7 struct RpcAccess
8 {
9  RpcAccess(const int port_, const std::string& user_, const std::string& password_, const std::string& serverIp_ = "localhost") :
10  port(std::to_string(port_)), rpcuser(user_), rpcpassword(password_), server(serverIp_) {}
11 
12  std::string port;
13  std::string rpcuser;
14  std::string rpcpassword;
15  std::string server; //"13.125.145.98"
16 };
17 
18 class RpcClient
19 {
20 public:
21  RpcClient(const RpcAccess& access, const std::string &chainName = "hdac", bool useSsl = false, const std::string& requestOut = "strerr") :
22  _accessInfo(access), _chainName(chainName), _fUseSSL(useSsl), _requestout(requestOut) {}
23 
24  RpcClient(const std::string& serverIp, int port, const std::string& user, const std::string& password, const std::string& chainName = "hdac",
25  bool useSsl = false, const std::string& requestOut = "strerr") :
26  RpcClient(RpcAccess(port, user, password, serverIp), chainName, useSsl, requestOut) {}
27 
28  RpcClient(int port, const std::string& user, const std::string& password, const std::string& chainName = "hdac",
29  bool useSsl = false, const std::string& requestOut = "strerr") :
30  RpcClient(RpcAccess(port, user, password), chainName, useSsl, requestOut) {}
31 
32 public:
33  json_spirit::Object CallRPC(const std::string& strMethod,
34  const json_spirit::Array& params = json_spirit::Array()) const;
35 
36 private:
37  RpcAccess _accessInfo;
38 
39  std::string _chainName;
40 
41  bool _fUseSSL; // default : not use ssl
42  std::string _requestout;
43 };
44 
45 #endif // RPCCLIENT_H
Definition: rpcclient.h:7
Definition: rpcclient.h:18