1 #ifndef RAPP_CLOUD_AVAILABLE_SERVICES
2 #define RAPP_CLOUD_AVAILABLE_SERVICES
21 const std::string token,
22 std::function<
void(std::vector<std::string>)> callback
26 header_ =
"GET /hop/available_services HTTP/1.1\r\n";
35 std::stringstream ss(json);
36 std::vector<std::string> services;
38 boost::property_tree::ptree tree;
39 boost::property_tree::read_json(ss, tree);
40 for (
auto child : tree.get_child(
"services")) {
41 services.push_back(child.second.get_value<std::string>());
43 for (
auto child : tree.get_child(
"error")) {
44 const std::string value = child.second.get_value<std::string>();
46 std::cerr <<
"available_services JSON error: " << value << std::endl;
50 catch (boost::property_tree::json_parser::json_parser_error & je) {
51 std::cerr <<
"available_services::handle_reply Error parsing: " << je.filename()
52 <<
" on line: " << je.line() << std::endl;
53 std::cerr << je.message() << std::endl;
58 std::function<void(std::vector<std::string> services)>
delegate_;
std::string header_
Header that will be used.
available_services(const std::string token, std::function< void(std::vector< std::string >)> callback)
construct without any special parameters
std::function< void(std::string)> callback_
Callback Handler - use with std::bind or boost variant.
void handle_reply(std::string json)
handle platform's JSON reply
requests available services from platform
base class for asynchronous http websockets used for connecting to cloud services ...
std::function< void(std::vector< std::string > services)> delegate_