Added rpc server spec

parent 962da83f
/**
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY!
*/
#ifndef JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
#define JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
#include <jsonrpccpp/server.h>
class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
{
public:
AbstractStubServer(jsonrpc::AbstractServerConnector &conn, jsonrpc::serverVersion_t type = jsonrpc::JSONRPC_SERVER_V2) : jsonrpc::AbstractServer<AbstractStubServer>(conn, type)
{
this->bindAndAddMethod(jsonrpc::Procedure("sayHello", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "name",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::sayHelloI);
this->bindAndAddNotification(jsonrpc::Procedure("notifyServer", jsonrpc::PARAMS_BY_NAME, NULL), &AbstractStubServer::notifyServerI);
this->bindAndAddMethod(jsonrpc::Procedure("addNumbers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::addNumbersI);
this->bindAndAddMethod(jsonrpc::Procedure("addNumbers2", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_REAL,"param2",jsonrpc::JSON_REAL, NULL), &AbstractStubServer::addNumbers2I);
this->bindAndAddMethod(jsonrpc::Procedure("isEqual", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::isEqualI);
this->bindAndAddMethod(jsonrpc::Procedure("buildObject", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::buildObjectI);
this->bindAndAddMethod(jsonrpc::Procedure("methodWithoutParameters", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, NULL), &AbstractStubServer::methodWithoutParametersI);
}
inline virtual void sayHelloI(const Json::Value &request, Json::Value &response)
{
response = this->sayHello(request["name"].asString());
}
inline virtual void notifyServerI(const Json::Value &request)
{
(void)request;
this->notifyServer();
}
inline virtual void addNumbersI(const Json::Value &request, Json::Value &response)
{
response = this->addNumbers(request[0u].asInt(), request[1u].asInt());
}
inline virtual void addNumbers2I(const Json::Value &request, Json::Value &response)
{
response = this->addNumbers2(request[0u].asDouble(), request[1u].asDouble());
}
inline virtual void isEqualI(const Json::Value &request, Json::Value &response)
{
response = this->isEqual(request[0u].asString(), request[1u].asString());
}
inline virtual void buildObjectI(const Json::Value &request, Json::Value &response)
{
response = this->buildObject(request[0u].asString(), request[1u].asInt());
}
inline virtual void methodWithoutParametersI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->methodWithoutParameters();
}
virtual std::string sayHello(const std::string& name) = 0;
virtual void notifyServer() = 0;
virtual int addNumbers(int param1, int param2) = 0;
virtual double addNumbers2(double param1, double param2) = 0;
virtual bool isEqual(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value buildObject(const std::string& param1, int param2) = 0;
virtual std::string methodWithoutParameters() = 0;
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
[
{
"name": "sayHello",
"params": {
"name": "Peter"
},
"returns": "Hello Peter"
},
{
"name": "notifyServer"
},
{
"name": "addNumbers",
"params": [
3,
4
],
"returns": 7
},
{
"name": "addNumbers2",
"params": [
3.2,
4.1
],
"returns": 7.5
},
{
"name": "isEqual",
"params": [
"string1",
"string2"
],
"returns": false
},
{
"name": "buildObject",
"params": [
"peter",
1990
],
"returns": {
"name": "peter",
"year": 1990
}
},
{
"name" : "methodWithoutParameters",
"returns": "String"
}
]
\ No newline at end of file
/**
* This file is generated by jsonrpcstub, DO NOT CHANGE IT MANUALLY!
*/
#ifndef JSONRPC_CPP_STUB_STUBCLIENT_H_
#define JSONRPC_CPP_STUB_STUBCLIENT_H_
#include <jsonrpccpp/client.h>
class StubClient : public jsonrpc::Client
{
public:
StubClient(jsonrpc::IClientConnector &conn, jsonrpc::clientVersion_t type = jsonrpc::JSONRPC_CLIENT_V2) : jsonrpc::Client(conn, type) {}
std::string sayHello(const std::string& name) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["name"] = name;
Json::Value result = this->CallMethod("sayHello",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
void notifyServer() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
this->CallNotification("notifyServer",p);
}
int addNumbers(int param1, int param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("addNumbers",p);
if (result.isIntegral())
return result.asInt();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
double addNumbers2(double param1, double param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("addNumbers2",p);
if (result.isDouble())
return result.asDouble();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool isEqual(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("isEqual",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value buildObject(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("buildObject",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string methodWithoutParameters() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("methodWithoutParameters",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
};
#endif //JSONRPC_CPP_STUB_STUBCLIENT_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment