8 int main(
int argc,
char* argv[])
11 std::cerr <<
"Usage: HelloClient serverHost serverPort\n";
14 int port = atoi(argv[2]);
20 for (
int i = 0; i < 2000; i++)
22 if (c.
execute(
"system.listMethods", noArgs, result))
23 std::cout <<
"\nMethods:\n " << result <<
"\n\n";
25 std::cout <<
"Error calling 'listMethods'\n\n";
31 if (c.
execute(
"system.methodHelp", oneArg, result))
32 std::cout <<
"Help for 'Hello' method: " << result <<
"\n\n";
34 std::cout <<
"Error calling 'methodHelp'\n\n";
37 if (c.
execute(
"Hello", noArgs, result))
38 std::cout << result <<
"\n\n";
40 std::cout <<
"Error calling 'Hello'\n\n";
44 if (c.
execute(
"HelloName", oneArg, result))
45 std::cout << result <<
"\n\n";
47 std::cout <<
"Error calling 'HelloName'\n\n";
54 std::cout <<
"numbers.size() is " << numbers.
size() << std::endl;
55 if (c.
execute(
"Sum", numbers, result))
56 std::cout <<
"Sum = " <<
double(result) <<
"\n\n";
58 std::cout <<
"Error calling 'Sum'\n\n";
61 if (c.
execute(
"NoSuchMethod", numbers, result))
62 std::cout <<
"NoSuchMethod call: fault: " << c.
isFault() <<
", result = " << result << std::endl;
64 std::cout <<
"Error calling 'Sum'\n";
68 multicall[0][0][
"methodName"] =
"Sum";
69 multicall[0][0][
"params"][0] = 5.0;
70 multicall[0][0][
"params"][1] = 9.0;
72 multicall[0][1][
"methodName"] =
"NoSuchMethod";
73 multicall[0][1][
"params"][0] =
"";
75 multicall[0][2][
"methodName"] =
"Sum";
78 multicall[0][3][
"methodName"] =
"Sum";
79 multicall[0][3][
"params"][0] = 10.5;
80 multicall[0][3][
"params"][1] = 12.5;
82 if (c.
execute(
"system.multicall", multicall, result))
83 std::cout <<
"\nmulticall result = " << result << std::endl;
85 std::cout <<
"\nError calling 'system.multicall'\n";
RPC method arguments and results are represented by Values.
int size() const
Return the size for string, base64, array, and struct values.
bool isFault() const
Returns true if the result of the last execute() was a fault response.
A class to send XML RPC requests to a server and return the results.
bool execute(const char *method, XmlRpcValue const ¶ms, XmlRpcValue &result)
int main(int argc, char *argv[])