summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/FacebookRM/src/client.h3
-rw-r--r--protocols/FacebookRM/src/communication.cpp17
2 files changed, 18 insertions, 2 deletions
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)