From 38203b745ae1903ba0804ed5532b78d255bea635 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 5 Aug 2018 11:14:39 -0400 Subject: Added timeline polling Because the streaming API will sunset on August 16th, it is essential to implement timeline polling so that the library can still be used to access tweets. This commit breaks the current API even for clients still using the streaming API because the OAuth connection data was pulled from twitter::client into twitter::auth. Other than that, almost everything works the same, and if a client wants to update their libtwitter++ within the next week and a half, they are free to. --- src/stream.h | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/stream.h') 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 @@ #include #include #include "bounding_box.h" +#include "auth.h" +#include "user.h" namespace twitter { - - class client; + class notification; - - class stream { + + class + [[deprecated("The Twitter streaming API will sunset on August 16th, 2018")]] + stream { public: - + typedef std::function notify_callback; - + stream( - const client& tclient, + const auth& tauth, notify_callback callback, bool with_followings = true, bool receive_all_replies = false, std::list track = {}, std::list locations = {}); - + ~stream(); - + stream(const stream& other) = delete; stream(stream&& other) = delete; stream& operator=(const stream& other) = delete; stream& operator=(stream&& other) = delete; - + private: enum class backoff { none, @@ -40,18 +43,18 @@ namespace twitter { http, rate_limit }; - + static std::string generateUrl( bool with_followings, bool receive_all_replies, std::list track, std::list locations); - + void run(std::string url); int progress(); size_t write(char* ptr, size_t size, size_t nmemb); - - const client& _client; + + const auth& _auth; notify_callback _notify; bool _stop = false; std::string _buffer; @@ -59,9 +62,10 @@ namespace twitter { bool _established = false; backoff _backoff_type = backoff::none; std::chrono::milliseconds _backoff_amount; + user _currentUser; std::thread _thread; }; - + } #endif /* end of include guard: STREAM_H_E9146952 */ -- cgit 1.4.1