forked from cinemast/libjson-rpc-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stubclient.cpp
37 lines (29 loc) · 1.15 KB
/
stubclient.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*************************************************************************
* libjson-rpc-cpp
*************************************************************************
* @file stubclient.cpp
* @date 01.05.2013
* @author Peter Spiess-Knafl <[email protected]>
* @license See attached LICENSE.txt
************************************************************************/
#include <iostream>
#include "gen/stubclient.h"
#include <jsonrpccpp/client/connectors/httpclient.h>
using namespace jsonrpc;
using namespace std;
int main() {
HttpClient httpclient("http://localhost:8383");
// StubClient c(httpclient, JSONRPC_CLIENT_V1); //json-rpc 1.0
StubClient c(httpclient, JSONRPC_CLIENT_V2); // json-rpc 2.0
try {
cout << c.sayHello("Peter Knafl") << endl;
c.notifyServer();
cout << " 3 + 5 = " << c.addNumbers(3, 5) << endl;
cout << " 3.2 + 5.3 = " << c.addNumbers2(3.2, 5.3) << endl;
cout << "Compare: " << c.isEqual("Peter", "peter") << endl;
cout << "Build object: " << c.buildObject("Peter", 1990) << endl;
c.sayHello(""); //expects a server error
} catch (JsonRpcException &e) {
cerr << e.what() << endl;
}
}