RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
geolocation.hpp
Go to the documentation of this file.
1 #ifndef RAPP_CLOUD_GEOLOCATION
2 #define RAPP_CLOUD_GEOLOCATION
3 #include "includes.ihh"
4 namespace rapp {
5 namespace cloud {
13 {
14 public:
22  const std::string ipaddr,
23  const std::string engine,
24  const std::string token,
25  std::function<void(std::string)> callback
26  )
27  : asio_service_http(token), delegate_(callback)
28  {
29  boost::property_tree::ptree tree;
30  tree.put("ipaddr", ipaddr);
31  tree.put("engine", engine);
32  std::stringstream ss;
33  boost::property_tree::write_json(ss, tree, false);
34  post_ = ss.str();
35  header_ = "POST /hop/geolocation HTTP/1.1\r\n"
36  + "Content-Type: application/x-www-form-urlencoded\r\n";
37  callback_ = std::bind(&geolocation::handle_reply, this, std::placeholders::_1);
38  }
39 private:
43  void handle_reply(std::string json)
44  {
45  std::stringstream ss(json);
46  delegate_(std::move(json));
47  }
49  std::function<void(std::string)> delegate_;
50 };
51 }
52 }
53 #endif
std::string header_
Header that will be used.
geolocation(const std::string ipaddr, const std::string engine, const std::string token, std::function< void(std::string)> callback)
Definition: geolocation.hpp:21
void handle_reply(std::string json)
handle platform's JSON reply
Definition: geolocation.hpp:43
std::string post_
Actual post Data.
std::function< void(std::string)> callback_
Callback Handler - use with std::bind or boost variant.
base class for asynchronous http websockets used for connecting to cloud services ...
std::function< void(std::string)> delegate_
Definition: geolocation.hpp:49
geolocation service
Definition: geolocation.hpp:12