You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pEpJSONServerAdapter/server/json_rpc.hh

38 lines
1011 B
C++

#ifndef JSON_RPC_HH
#define JSON_RPC_HH
#include "json_spirit/json_spirit_value.h"
#include "function_map.hh"
namespace js = json_spirit;
enum class JSON_RPC
{
PARSE_ERROR = -32700,
INVALID_REQUEST = -32600,
METHOD_NOT_FOUND = -32601,
INVALID_PARAMS = -32602,
INTERNAL_ERROR = -32603,
};
class JsonAdapterBase;
7 years ago
// Server side:
7 years ago
// parse the JSON-RPC 2.0 compatible "request", call the C function
// and create an appropiate "response" object (containing a result or an error)
js::Object call(const FunctionMap& fm, const js::Object& request, JsonAdapterBase* ja);
// create a JSON-RPC 2.0 compatible result response object
//js::Object make_result(const js::Value& result, int id);
// create a JSON-RPC 2.0 compatible error response object
js::Object make_error(JSON_RPC error_code, const std::string& error_message, const js::Value& data, int id);
// for events to clients:
js::Object make_request(const std::string& functionName, const js::Array& parameters);
7 years ago
#endif // JSON_RPC_HH