diff options
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/client.cpp b/src/client.cpp index c6bcd65..b7d1624 100644 --- a/src/client.cpp +++ b/src/client.cpp | |||
@@ -410,6 +410,11 @@ namespace twitter { | |||
410 | _user_stream.setNotifyCallback(callback); | 410 | _user_stream.setNotifyCallback(callback); |
411 | } | 411 | } |
412 | 412 | ||
413 | void client::setUserStreamReceiveAllReplies(bool _arg) | ||
414 | { | ||
415 | _user_stream.setReceiveAllReplies(_arg); | ||
416 | } | ||
417 | |||
413 | void client::startUserStream() | 418 | void client::startUserStream() |
414 | { | 419 | { |
415 | _user_stream.start(); | 420 | _user_stream.start(); |
@@ -614,8 +619,22 @@ namespace twitter { | |||
614 | 619 | ||
615 | void client::stream::setNotifyCallback(notify_callback _n) | 620 | void client::stream::setNotifyCallback(notify_callback _n) |
616 | { | 621 | { |
617 | std::lock_guard<std::mutex> _notify_lock(_notify_mutex); | 622 | std::lock_guard<std::mutex> _running_lock(_running_mutex); |
618 | _notify = _n; | 623 | |
624 | if (!_thread.joinable()) | ||
625 | { | ||
626 | _notify = _n; | ||
627 | } | ||
628 | } | ||
629 | |||
630 | void client::stream::setReceiveAllReplies(bool _arg) | ||
631 | { | ||
632 | std::lock_guard<std::mutex> _running_lock(_running_mutex); | ||
633 | |||
634 | if (!_thread.joinable()) | ||
635 | { | ||
636 | _receive_all_replies = _arg; | ||
637 | } | ||
619 | } | 638 | } |
620 | 639 | ||
621 | void client::stream::start() | 640 | void client::stream::start() |
@@ -643,8 +662,15 @@ namespace twitter { | |||
643 | void client::stream::run() | 662 | void client::stream::run() |
644 | { | 663 | { |
645 | curl::curl_easy conn; | 664 | curl::curl_easy conn; |
646 | std::string url = "https://userstream.twitter.com/1.1/user.json"; | 665 | std::ostringstream urlstr; |
666 | urlstr << "https://userstream.twitter.com/1.1/user.json"; | ||
647 | 667 | ||
668 | if (_receive_all_replies) | ||
669 | { | ||
670 | urlstr << "?replies=all"; | ||
671 | } | ||
672 | |||
673 | std::string url = urlstr.str(); | ||
648 | curl::curl_header headers; | 674 | curl::curl_header headers; |
649 | std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); | 675 | std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); |
650 | if (!oauth_header.empty()) | 676 | if (!oauth_header.empty()) |
@@ -768,13 +794,9 @@ namespace twitter { | |||
768 | _backoff_amount = std::chrono::milliseconds(0); | 794 | _backoff_amount = std::chrono::milliseconds(0); |
769 | } | 795 | } |
770 | 796 | ||
797 | if (_notify) | ||
771 | { | 798 | { |
772 | std::lock_guard<std::mutex> _notify_lock(_notify_mutex); | 799 | _notify(n); |
773 | |||
774 | if (_notify) | ||
775 | { | ||
776 | _notify(n); | ||
777 | } | ||
778 | } | 800 | } |
779 | 801 | ||
780 | _buffer = ""; | 802 | _buffer = ""; |