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

Function main

src/examples/stubclient.cpp:18–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16using namespace std;
17
18int main() {
19 HttpClient httpclient("http://localhost:8383");
20 // StubClient c(httpclient, JSONRPC_CLIENT_V1); //json-rpc 1.0
21 StubClient c(httpclient, JSONRPC_CLIENT_V2); // json-rpc 2.0
22
23 try {
24 cout << c.sayHello("Peter Knafl") << endl;
25 c.notifyServer();
26
27 cout << " 3 + 5 = " << c.addNumbers(3, 5) << endl;
28 cout << " 3.2 + 5.3 = " << c.addNumbers2(3.2, 5.3) << endl;
29 Json::Value args;
30 args["arg1"] = 1;
31 args["arg2"] = 2;
32 args["operator"] = "+";
33 Json::Value result = c.calculate(args);
34 cout << " 1 + 2 = " << result[0].asInt() << endl;
35 args["arg1"] = 3;
36 args["arg2"] = 4;
37 args["operator"] = "*";
38 result = c.calculate(args);
39 cout << " 3 * 4 = " << result[0].asInt() << endl;
40 cout << "Compare: " << c.isEqual("Peter", "peter") << endl;
41 cout << "Build object: " << c.buildObject("Peter", 1990) << endl;
42
43 c.sayHello(""); // expects a server error
44
45 } catch (JsonRpcException &e) {
46 cerr << e.what() << endl;
47 }
48}

Callers

nothing calls this directly

Calls 8

sayHelloMethod · 0.45
notifyServerMethod · 0.45
addNumbersMethod · 0.45
addNumbers2Method · 0.45
calculateMethod · 0.45
isEqualMethod · 0.45
buildObjectMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected