diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-06-02 20:10:08 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-06-02 20:10:08 -0400 |
commit | e506eb6214ac1799ce7d7e333cfab965a11d5917 (patch) | |
tree | f0fb74bdb705f4bf06d2cb670205762f9fd1eea9 /src/client.cpp | |
parent | 501880160ac69f90143bc38add541731a9242ab0 (diff) | |
download | libtwittercpp-e506eb6214ac1799ce7d7e333cfab965a11d5917.tar.gz libtwittercpp-e506eb6214ac1799ce7d7e333cfab965a11d5917.tar.bz2 libtwittercpp-e506eb6214ac1799ce7d7e333cfab965a11d5917.zip |
Fixed user stream unable-to-reconnect issue
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/client.cpp b/src/client.cpp index b7d1624..51c288d 100644 --- a/src/client.cpp +++ b/src/client.cpp | |||
@@ -661,7 +661,6 @@ namespace twitter { | |||
661 | 661 | ||
662 | void client::stream::run() | 662 | void client::stream::run() |
663 | { | 663 | { |
664 | curl::curl_easy conn; | ||
665 | std::ostringstream urlstr; | 664 | std::ostringstream urlstr; |
666 | urlstr << "https://userstream.twitter.com/1.1/user.json"; | 665 | urlstr << "https://userstream.twitter.com/1.1/user.json"; |
667 | 666 | ||
@@ -671,29 +670,31 @@ namespace twitter { | |||
671 | } | 670 | } |
672 | 671 | ||
673 | std::string url = urlstr.str(); | 672 | std::string url = urlstr.str(); |
674 | curl::curl_header headers; | ||
675 | std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); | ||
676 | if (!oauth_header.empty()) | ||
677 | { | ||
678 | headers.add(oauth_header); | ||
679 | } | ||
680 | |||
681 | conn.add<CURLOPT_WRITEFUNCTION>(client_stream_write_callback_wrapper); | ||
682 | conn.add<CURLOPT_WRITEDATA>(this); | ||
683 | conn.add<CURLOPT_HEADERFUNCTION>(nullptr); | ||
684 | conn.add<CURLOPT_HEADERDATA>(nullptr); | ||
685 | conn.add<CURLOPT_XFERINFOFUNCTION>(client_stream_progress_callback_wrapper); | ||
686 | conn.add<CURLOPT_XFERINFODATA>(this); | ||
687 | conn.add<CURLOPT_NOPROGRESS>(0); | ||
688 | //conn.add<CURLOPT_VERBOSE>(1); | ||
689 | //conn.add<CURLOPT_DEBUGFUNCTION>(my_trace); | ||
690 | conn.add<CURLOPT_URL>(url.c_str()); | ||
691 | conn.add<CURLOPT_HTTPHEADER>(headers.get()); | ||
692 | 673 | ||
693 | _backoff_type = backoff::none; | 674 | _backoff_type = backoff::none; |
694 | _backoff_amount = std::chrono::milliseconds(0); | 675 | _backoff_amount = std::chrono::milliseconds(0); |
695 | for (;;) | 676 | for (;;) |
696 | { | 677 | { |
678 | curl::curl_easy conn; | ||
679 | curl::curl_header headers; | ||
680 | std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); | ||
681 | if (!oauth_header.empty()) | ||
682 | { | ||
683 | headers.add(oauth_header); | ||
684 | } | ||
685 | |||
686 | conn.add<CURLOPT_WRITEFUNCTION>(client_stream_write_callback_wrapper); | ||
687 | conn.add<CURLOPT_WRITEDATA>(this); | ||
688 | conn.add<CURLOPT_HEADERFUNCTION>(nullptr); | ||
689 | conn.add<CURLOPT_HEADERDATA>(nullptr); | ||
690 | conn.add<CURLOPT_XFERINFOFUNCTION>(client_stream_progress_callback_wrapper); | ||
691 | conn.add<CURLOPT_XFERINFODATA>(this); | ||
692 | conn.add<CURLOPT_NOPROGRESS>(0); | ||
693 | //conn.add<CURLOPT_VERBOSE>(1); | ||
694 | //conn.add<CURLOPT_DEBUGFUNCTION>(my_trace); | ||
695 | conn.add<CURLOPT_URL>(url.c_str()); | ||
696 | conn.add<CURLOPT_HTTPHEADER>(headers.get()); | ||
697 | |||
697 | bool failure = false; | 698 | bool failure = false; |
698 | try { | 699 | try { |
699 | conn.perform(); | 700 | conn.perform(); |