Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed response handlers for 'me', 'c', and related commands #3204

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion example/cpp/td_example.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Aliaksei Levin ([email protected]), Arseny Smirnov ([email protected]) 2014-2024
// Copyright Aliaksei Levin ([email protected]), Arseny Smirnov ([email protected]) 2014-2025
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -84,6 +84,10 @@ class TdExample {
auto response = client_manager_->receive(0);
if (response.object) {
process_response(std::move(response));
if (response.request_id != 0 && response.request_id == last_user_query_) {
std::cout << "Response to last user query_id: " << response.request_id << " received!" << std::endl;
break;
}
} else {
break;
}
Expand All @@ -94,6 +98,8 @@ class TdExample {
} else if (action == "me") {
send_query(td_api::make_object<td_api::getMe>(),
[this](Object object) { std::cout << to_string(object) << std::endl; });
last_user_query_ = current_query_id_;
std::cout << "user query_id sent: " << last_user_query_ << std::endl;
} else if (action == "l") {
std::cout << "Logging out..." << std::endl;
send_query(td_api::make_object<td_api::logOut>(), {});
Expand Down Expand Up @@ -124,6 +130,8 @@ class TdExample {
std::cout << "[chat_id:" << chat_id << "] [title:" << chat_title_[chat_id] << "]" << std::endl;
}
});
last_user_query_ = current_query_id_;
std::cout << "user query_id sent: " << last_user_query_ << std::endl;
}
}
}
Expand All @@ -139,6 +147,7 @@ class TdExample {
bool need_restart_{false};
std::uint64_t current_query_id_{0};
std::uint64_t authentication_query_id_{0};
std::uint64_t last_user_query_{0};

std::map<std::uint64_t, std::function<void(Object)>> handlers_;

Expand Down