From 64e08ea58c8b68bdf5f0e027c32b106dc4b8aa1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Tue, 11 Mar 2014 20:49:31 +0000 Subject: Facebook: Hotfix for sticky number (some FB API update), version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@8564 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/client.h | 4 ++- protocols/FacebookRM/src/communication.cpp | 47 +++++++++++++++--------------- protocols/FacebookRM/src/version.h | 4 +-- 3 files changed, 28 insertions(+), 27 deletions(-) (limited to 'protocols/FacebookRM') diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 798d17843c..ab701f4a15 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_ = ""; + dtsg_ = logout_hash_ = chat_sticky_num_ = chat_conn_num_ = ""; msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = 0; @@ -73,6 +73,8 @@ public: std::string chat_channel_partition_; std::string chat_sequence_num_; std::string chat_reconnect_reason_; + std::string chat_sticky_num_; + std::string chat_conn_num_; bool invisible_; bool is_typing_; bool is_idle_; diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 544fb3f066..6168a26f8c 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -303,7 +303,7 @@ std::string facebook_client::choose_server(RequestType request_type, std::string case REQUEST_MESSAGES_RECEIVE: { std::string server = FACEBOOK_SERVER_CHAT; - utils::text::replace_first(&server, "%s", "0"); + utils::text::replace_first(&server, "%s", this->chat_conn_num_.empty() ? "0" : this->chat_conn_num_); utils::text::replace_first(&server, "%s", this->chat_channel_host_); return server; } @@ -500,6 +500,9 @@ std::string facebook_client::choose_action(RequestType request_type, std::string action += "&seq=" + (this->chat_sequence_num_.empty() ? "0" : this->chat_sequence_num_); action += "&partition=" + (this->chat_channel_partition_.empty() ? "0" : this->chat_channel_partition_); action += "&clientid=&cb=&idle=0&state=active"; + if (!this->chat_sticky_num_.empty()) + action += "&sticky_token=" + this->chat_sticky_num_; + return action; } @@ -950,6 +953,9 @@ bool facebook_client::reconnect() 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()); + this->chat_conn_num_ = utils::text::source_get_value2(&resp.data, "\"max_conn\":", ",}"); + parent->debugLogA(" Got self max_conn: %s", this->chat_conn_num_.c_str()); + return handle_success("reconnect"); } @@ -1089,39 +1095,32 @@ bool facebook_client::channel() // Get update http::response resp = flap(REQUEST_MESSAGES_RECEIVE); - if (resp.code != HTTP_CODE_OK) - { - // Something went wrong - } - else if (resp.data.find("\"t\":\"continue\"") != std::string::npos) - { + std::string type = utils::text::source_get_value(&resp.data, 2, "\"t\":\"", "\""); + if (type == "continue" || type == "heartbeat") { // Everything is OK, no new message received } - else if (resp.data.find("\"t\":\"fullReload\"") != std::string::npos) - { + else if (type == "lb") { + // Some new stuff (idk how does it work yet) + this->chat_channel_host_ = utils::text::source_get_value(&resp.data, 2, "\"vip\":\"", "\""); + parent->debugLogA(" Got self channel host: %s", this->chat_channel_host_.c_str()); + + this->chat_sticky_num_ = utils::text::source_get_value2(&resp.data, "\"sticky\":\"", "\""); + parent->debugLogA(" Got self sticky number: %s", this->chat_sticky_num_.c_str()); + } + else if (type == "fullReload" || type == "refresh") { // Something went wrong (server flooding?) + parent->debugLogA("! ! ! Requested %s", type.c_str()); - parent->debugLogA("! ! ! Requested full reload"); - 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()); this->chat_reconnect_reason_ = utils::text::source_get_value2(&resp.data, "\"reason\":", ",}"); parent->debugLogA(" Reconnect reason: %s", this->chat_reconnect_reason_.c_str()); - } - else if (resp.data.find("\"t\":\"refresh\"") != std::string::npos) - { - // Something went wrong (server flooding?) - parent->debugLogA("! ! ! Requested channel refresh"); - - this->chat_reconnect_reason_ = utils::text::source_get_value2(&resp.data, "\"reason\":", ",}"); - parent->debugLogA(" Reconnect reason: %s", this->chat_reconnect_reason_.c_str()); - 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()); - - return this->reconnect(); - } else { + if (type == "refresh") + return this->reconnect(); + } + else { // 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); diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 937c576226..180e78fcd0 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 -#define __RELEASE_NUM 2 -#define __BUILD_NUM 1 +#define __RELEASE_NUM 3 +#define __BUILD_NUM 0 #include -- cgit v1.2.3