-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.cpp
More file actions
37 lines (26 loc) · 769 Bytes
/
test2.cpp
File metadata and controls
37 lines (26 loc) · 769 Bytes
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
#include "rate_limited_http_handler.hpp"
#include <iostream>
#include <thread>
int main() {
RateLimitedHttpHandler handler;
handler.AddUrl(
"https://api.exchange.coinbase.com/products/BTC-USD/ticker",
"coinbase",
2000 // 2 s
);
handler.AddUrl(
"https://api.gemini.com/v1/pubticker/btcusd",
"gemini",
3000 // 3 s
);
std::cout << "Starting rate-limited HTTP polling...\n";
while (true) {
auto results = handler.http_update();
for (const auto& r : results) {
std::cout << "[" << r.exchange << "] response = "
<< r.response << " \n";
}
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
return 0;
}