From 69fc8d805396b889b5e8c1c88e8129d93db77d29 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 20 Aug 2016 13:56:23 -0400 Subject: Updated API to use exceptions and make tweet/user objects more helpful --- src/stream.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/stream.h (limited to 'src/stream.h') diff --git a/src/stream.h b/src/stream.h new file mode 100644 index 0000000..3391912 --- /dev/null +++ b/src/stream.h @@ -0,0 +1,67 @@ +#ifndef STREAM_H_E9146952 +#define STREAM_H_E9146952 + +#include +#include +#include +#include +#include +#include "bounding_box.h" + +namespace twitter { + + class client; + class notification; + + class stream { + public: + + typedef std::function notify_callback; + + stream( + const client& tclient, + 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, + network, + 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; + notify_callback _notify; + bool _stop = false; + std::string _buffer; + time_t _last_write; + bool _established = false; + backoff _backoff_type = backoff::none; + std::chrono::milliseconds _backoff_amount; + std::thread _thread; + }; + +} + +#endif /* end of include guard: STREAM_H_E9146952 */ -- cgit 1.4.1