From e506eb6214ac1799ce7d7e333cfab965a11d5917 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 2 Jun 2016 20:10:08 -0400 Subject: Fixed user stream unable-to-reconnect issue --- src/client.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src/client.cpp') 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 { void client::stream::run() { - curl::curl_easy conn; std::ostringstream urlstr; urlstr << "https://userstream.twitter.com/1.1/user.json"; @@ -671,29 +670,31 @@ namespace twitter { } std::string url = urlstr.str(); - curl::curl_header headers; - std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); - if (!oauth_header.empty()) - { - headers.add(oauth_header); - } - - conn.add(client_stream_write_callback_wrapper); - conn.add(this); - conn.add(nullptr); - conn.add(nullptr); - conn.add(client_stream_progress_callback_wrapper); - conn.add(this); - conn.add(0); - //conn.add(1); - //conn.add(my_trace); - conn.add(url.c_str()); - conn.add(headers.get()); _backoff_type = backoff::none; _backoff_amount = std::chrono::milliseconds(0); for (;;) { + curl::curl_easy conn; + curl::curl_header headers; + std::string oauth_header = _client._oauth_client->getFormattedHttpHeader(OAuth::Http::Get, url, ""); + if (!oauth_header.empty()) + { + headers.add(oauth_header); + } + + conn.add(client_stream_write_callback_wrapper); + conn.add(this); + conn.add(nullptr); + conn.add(nullptr); + conn.add(client_stream_progress_callback_wrapper); + conn.add(this); + conn.add(0); + //conn.add(1); + //conn.add(my_trace); + conn.add(url.c_str()); + conn.add(headers.get()); + bool failure = false; try { conn.perform(); -- cgit 1.4.1