From dd9f965fb221b92a4888558df1318bc70295c00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 16 Jul 2014 07:54:37 +0000 Subject: Facebook: Update channel request with traceid git-svn-id: http://svn.miranda-ng.org/main/trunk@9822 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/client.h | 3 ++- protocols/FacebookRM/src/communication.cpp | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'protocols') diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index d62d5d27cb..c1b3a5fc49 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -39,7 +39,7 @@ public: { username_ = password_ = \ chat_sequence_num_ = chat_channel_host_ = chat_channel_partition_ = \ - dtsg_ = logout_hash_ = chat_sticky_num_ = chat_conn_num_ = chat_clientid_ = ""; + dtsg_ = logout_hash_ = chat_sticky_num_ = chat_conn_num_ = chat_clientid_ = chat_traceid_ = ""; msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = 0; @@ -76,6 +76,7 @@ public: std::string chat_sticky_num_; std::string chat_conn_num_; std::string chat_clientid_; + std::string chat_traceid_; bool is_typing_; bool is_idle_; bool https_; diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 5f29f113b0..f3e0c19c85 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -523,9 +523,14 @@ std::string facebook_client::choose_action(RequestType request_type, std::string else action += "&idle=1"; + action += "&cap=0"; + if (!this->chat_sticky_num_.empty()) action += "&sticky_token=" + this->chat_sticky_num_; + if (!this->chat_traceid_.empty()) + action += "&traceid=" + this->chat_traceid_; + return action; } @@ -1044,6 +1049,12 @@ bool facebook_client::channel() return handle_error("channel"); } + // Load traceId, if present + std::string traceId = utils::text::source_get_value(&resp.data, 2, "\"tr\":\"", "\""); + if (!traceId.empty()) { + this->chat_traceid_ = traceId; + } + std::string type = utils::text::source_get_value(&resp.data, 2, "\"t\":\"", "\""); if (type == "continue" || type == "heartbeat") { // Everything is OK, no new message received @@ -1069,7 +1080,7 @@ bool facebook_client::channel() if (type == "refresh") return this->reconnect(); } - else { + else if (!type.empty()) { // Something has been received, throw to new thread to process std::string* response_data = new std::string(resp.data); parent->ForkThread(&FacebookProto::ProcessMessages, response_data); @@ -1078,6 +1089,10 @@ bool facebook_client::channel() this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}"); parent->debugLogA(" Got self sequence number: %s", this->chat_sequence_num_.c_str()); } + else { + // No type? This shouldn't happen unless there is a big API change. + return handle_error("channel"); + } // Return switch (resp.code) -- cgit v1.2.3