Dev Essential  1.6.3
Loading...
Searching...
No Matches
json_rpc.h
Go to the documentation of this file.
1
14
15#ifndef PKG_RPC_JSON_RPC_H_INCLUDED
16#define PKG_RPC_JSON_RPC_H_INCLUDED
17
18#include <rpc/rpc_server.h>
19
20#include <jsonrpccpp/client/iclientconnector.h>
21#include <jsonrpccpp/server/abstractserverconnector.h>
22
23namespace rpc {
24
29public:
35 static Json::Value result_to_json(a_util::result::Result nResult);
36#ifndef PKGRPC_NO_TOSTRING
42 static std::string to_string(uint64_t nValue);
48 static std::string to_string(int64_t nValue);
49#endif // PKGRPC_NO_TOSTRING
55 static a_util::result::Result json_to_result(const Json::Value& oValue);
61 static uint64_t stoull(const std::string& strValue);
67 static int64_t stoll(const std::string& strValue);
68};
69
76template <typename Stub, typename Connector, typename ConnectorInitializer>
77class jsonrpc_remote_object : private Connector, public Stub {
78public:
84 jsonrpc_remote_object(const ConnectorInitializer& oInitializer);
85
86protected:
91 Stub& GetStub() const;
92};
93
101template <typename Stub, typename Interface, typename Connector, typename ConnectorInitializer>
103 : private jsonrpc_remote_object<Stub, Connector, ConnectorInitializer>,
104 protected cJSONConversions,
105 public Interface {
106public:
112 jsonrpc_remote_interface(const ConnectorInitializer& oInitializer);
113
114protected:
119 Stub& GetStub() const;
120};
121
125class cServerConnector : public jsonrpc::AbstractServerConnector {
126public:
143 bool SendResponse(const std::string& response, void* addInfo);
150 bool OnRequest(const std::string& request, IResponse* response);
151};
152
158template <typename ServerStub, typename Connector = cServerConnector>
159class jsonrpc_object_server : protected Connector,
160 protected ServerStub,
161 public IRPCObject,
162 protected cJSONConversions {
163public:
166
167public:
174 virtual a_util::result::Result HandleCall(const char* strRequest,
175 size_t nRequestSize,
176 IResponse& oResponse);
177};
178
179} // namespace rpc
180
181#endif // PKG_RPC_HTTP_RPC_PROTOCOL_H_INCLUDED
182
Definition result_type_decl.h:34
Definition rpc_server.h:47
Definition rpc_server.h:34
Definition json_rpc.h:28
static std::string to_string(uint64_t nValue)
static a_util::result::Result json_to_result(const Json::Value &oValue)
static std::string to_string(int64_t nValue)
static Json::Value result_to_json(a_util::result::Result nResult)
static uint64_t stoull(const std::string &strValue)
static int64_t stoll(const std::string &strValue)
Definition json_rpc.h:125
bool SendResponse(const std::string &response, void *addInfo)
bool OnRequest(const std::string &request, IResponse *response)
virtual a_util::result::Result HandleCall(const char *strRequest, size_t nRequestSize, IResponse &oResponse)
Definition json_rpc_impl.h:56
jsonrpc_object_server()
CTOR.
Definition json_rpc_impl.h:50
Stub & GetStub() const
Definition json_rpc_impl.h:43
jsonrpc_remote_interface(const ConnectorInitializer &oInitializer)
Definition json_rpc_impl.h:37
jsonrpc_remote_object(const ConnectorInitializer &oInitializer)
Definition json_rpc_impl.h:23
Stub & GetStub() const
Definition json_rpc_impl.h:30
definition of the rpc namespace
Definition json_rpc_impl.h:20