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 38 39
|
#include <iostream>
#include <cxxtools/arg.h>
#include <cxxtools/log.h>
#include <cxxtools/remoteprocedure.h>
#include <cxxtools/json/httpclient.h>
////////////////////////////////////////////////////////////////////////
// main
//
int main(int argc, char* argv[])
{
try
{
log_init();
cxxtools::Arg<std::string> ip(argc, argv, 'i');
cxxtools::Arg<unsigned short> port(argc, argv, 'p', 7002);
cxxtools::Arg<std::string> cert(argc, argv, 'c');
cxxtools::Arg<std::string> ca(argc, argv, 'C');
cxxtools::json::HttpClient client(ip, port, "/jsonrpc", cert);
if (ca.isSet())
client.setSslVerify(2, ca);
cxxtools::RemoteProcedure<std::string, std::string> echo(client, "echo");
for (int a = 1; a < argc; ++a)
{
std::string v = echo(argv[a]);
std::cout << v << '\n';
}
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
}
|