diff options
Diffstat (limited to 'src/stream.h')
-rw-r--r-- | src/stream.h | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/stream.h b/src/stream.h index b682ce2..f6ce91e 100644 --- a/src/stream.h +++ b/src/stream.h | |||
@@ -7,32 +7,35 @@ | |||
7 | #include <chrono> | 7 | #include <chrono> |
8 | #include <thread> | 8 | #include <thread> |
9 | #include "bounding_box.h" | 9 | #include "bounding_box.h" |
10 | #include "auth.h" | ||
11 | #include "user.h" | ||
10 | 12 | ||
11 | namespace twitter { | 13 | namespace twitter { |
12 | 14 | ||
13 | class client; | ||
14 | class notification; | 15 | class notification; |
15 | 16 | ||
16 | class stream { | 17 | class |
18 | [[deprecated("The Twitter streaming API will sunset on August 16th, 2018")]] | ||
19 | stream { | ||
17 | public: | 20 | public: |
18 | 21 | ||
19 | typedef std::function<void(notification _notification)> notify_callback; | 22 | typedef std::function<void(notification _notification)> notify_callback; |
20 | 23 | ||
21 | stream( | 24 | stream( |
22 | const client& tclient, | 25 | const auth& tauth, |
23 | notify_callback callback, | 26 | notify_callback callback, |
24 | bool with_followings = true, | 27 | bool with_followings = true, |
25 | bool receive_all_replies = false, | 28 | bool receive_all_replies = false, |
26 | std::list<std::string> track = {}, | 29 | std::list<std::string> track = {}, |
27 | std::list<bounding_box> locations = {}); | 30 | std::list<bounding_box> locations = {}); |
28 | 31 | ||
29 | ~stream(); | 32 | ~stream(); |
30 | 33 | ||
31 | stream(const stream& other) = delete; | 34 | stream(const stream& other) = delete; |
32 | stream(stream&& other) = delete; | 35 | stream(stream&& other) = delete; |
33 | stream& operator=(const stream& other) = delete; | 36 | stream& operator=(const stream& other) = delete; |
34 | stream& operator=(stream&& other) = delete; | 37 | stream& operator=(stream&& other) = delete; |
35 | 38 | ||
36 | private: | 39 | private: |
37 | enum class backoff { | 40 | enum class backoff { |
38 | none, | 41 | none, |
@@ -40,18 +43,18 @@ namespace twitter { | |||
40 | http, | 43 | http, |
41 | rate_limit | 44 | rate_limit |
42 | }; | 45 | }; |
43 | 46 | ||
44 | static std::string generateUrl( | 47 | static std::string generateUrl( |
45 | bool with_followings, | 48 | bool with_followings, |
46 | bool receive_all_replies, | 49 | bool receive_all_replies, |
47 | std::list<std::string> track, | 50 | std::list<std::string> track, |
48 | std::list<bounding_box> locations); | 51 | std::list<bounding_box> locations); |
49 | 52 | ||
50 | void run(std::string url); | 53 | void run(std::string url); |
51 | int progress(); | 54 | int progress(); |
52 | size_t write(char* ptr, size_t size, size_t nmemb); | 55 | size_t write(char* ptr, size_t size, size_t nmemb); |
53 | 56 | ||
54 | const client& _client; | 57 | const auth& _auth; |
55 | notify_callback _notify; | 58 | notify_callback _notify; |
56 | bool _stop = false; | 59 | bool _stop = false; |
57 | std::string _buffer; | 60 | std::string _buffer; |
@@ -59,9 +62,10 @@ namespace twitter { | |||
59 | bool _established = false; | 62 | bool _established = false; |
60 | backoff _backoff_type = backoff::none; | 63 | backoff _backoff_type = backoff::none; |
61 | std::chrono::milliseconds _backoff_amount; | 64 | std::chrono::milliseconds _backoff_amount; |
65 | user _currentUser; | ||
62 | std::thread _thread; | 66 | std::thread _thread; |
63 | }; | 67 | }; |
64 | 68 | ||
65 | } | 69 | } |
66 | 70 | ||
67 | #endif /* end of include guard: STREAM_H_E9146952 */ | 71 | #endif /* end of include guard: STREAM_H_E9146952 */ |