-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfutures_user_stream.cpp
55 lines (41 loc) · 1.12 KB
/
futures_user_stream.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "../include/Binance_Client.h"
#include <thread>
#include <iostream>
struct SomeFunctor
{
Json::CharReaderBuilder charbuilder;
Json::CharReader* charreader;
std::string parse_errors;
Json::Value stream_msg;
SomeFunctor()
: parse_errors{ }, charreader{ charbuilder.newCharReader() }
{}
SomeFunctor operator()(const std::string& response)
{
this->stream_msg.clear();
this->parse_errors.clear();
this->charreader->parse(response.c_str(),
response.c_str() + response.size(),
&this->stream_msg,
&parse_errors);
std::cout << this->stream_msg;
return *this;
}
};
int main()
{
try
{
std::string api_key{ "key" };
std::string api_secret{ "secret" };
FuturesClientUSDT my_client{ api_key, api_secret };
SomeFunctor ws_stream_read{};
std::thread t1(&FuturesClientUSDT::stream_userStream<SomeFunctor>, std::ref(my_client), std::ref(ws_stream_read), 1);
t1.join();
}
catch (ClientException& e)
{
std::cout << e.what();
}
return 0;
}