Elma
An event loop manager for embedded systems
client.h
1 #ifndef _ELMA_CLIENT_H
2 #define _ELMA_CLIENT_H
3 
4 // #define CPPHTTPLIB_OPENSSL_SUPPORT
5 #include "httplib/httplib.h"
6 
7 #include <string>
8 #include <tuple>
9 #include "elma.h"
10 
11 namespace elma {
12 
14 
34  class Client {
35 
36  public:
37 
40  Client() : _use_ssl(false) {}
41 
48  Client& get(std::string url, std::function<void(json&)> handler);
49 
53 
57  std::pair<std::string,std::string> url_parts(std::string url);
58 
60  int num_responses() const { return _responses.size(); }
61 
62  private:
63 
64  void _get_thread(std::string url, std::function<void(json&)> handler);
65  const std::shared_ptr<httplib::Response> _get_aux(std::string url);
66  std::vector<std::tuple<json, std::function<void(json&)>>> _responses;
67  bool _use_ssl;
68  std::mutex _mtx;
69 
70  };
71 
72 }
73 
74 #endif
int num_responses() const
Definition: client.h:60
std::pair< std::string, std::string > url_parts(std::string url)
Definition: client.cc:10
An HTTP client for connecting to json services.
Definition: client.h:34
Definition: channel.cc:5
Client & process_responses()
Definition: client.cc:39