MCPcopy Create free account
hub / github.com/cinemast/libjson-rpc-cpp / TestServer

Method TestServer

src/test/testserver.cpp:16–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace jsonrpc;
15
16TestServer::TestServer(AbstractServerConnector &connector, serverVersion_t type) : AbstractServer<TestServer>(connector, type), cnt(-1) {
17 this->bindAndAddMethod(Procedure("sayHello", PARAMS_BY_NAME, JSON_STRING, "name", JSON_STRING, NULL), &TestServer::sayHello);
18 this->bindAndAddMethod(Procedure("getCounterValue", PARAMS_BY_NAME, JSON_INTEGER, NULL), &TestServer::getCounterValue);
19 this->bindAndAddMethod(Procedure("add", PARAMS_BY_NAME, JSON_INTEGER, "value1", JSON_INTEGER, "value2", JSON_INTEGER, NULL), &TestServer::add);
20 this->bindAndAddMethod(Procedure("sub", PARAMS_BY_POSITION, JSON_INTEGER, "value1", JSON_INTEGER, "value2", JSON_INTEGER, NULL), &TestServer::sub);
21 this->bindAndAddMethod(Procedure("exceptionMethod", PARAMS_BY_POSITION, JSON_INTEGER, NULL), &TestServer::exceptionMethod);
22
23 this->bindAndAddNotification(Procedure("initCounter", PARAMS_BY_NAME, "value", JSON_INTEGER, NULL), &TestServer::initCounter);
24 this->bindAndAddNotification(Procedure("incrementCounter", PARAMS_BY_NAME, "value", JSON_INTEGER, NULL), &TestServer::incrementCounter);
25 this->bindAndAddNotification(Procedure("initZero", PARAMS_BY_POSITION, NULL), &TestServer::initZero);
26}
27
28void TestServer::sayHello(const Json::Value &request, Json::Value &response) { response = "Hello: " + request["name"].asString() + "!"; }
29

Callers

nothing calls this directly

Calls 3

bindAndAddMethodMethod · 0.95
ProcedureClass · 0.50

Tested by

no test coverage detected