Add Td::do_run_request.
This commit is contained in:
parent
98a2dc2a45
commit
a24af09922
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
td_api::object_ptr<td_api::Object> SynchronousRequests::run_request(td_api::object_ptr<td_api::Function> function) {
|
td_api::object_ptr<td_api::Object> SynchronousRequests::run_request(td_api::object_ptr<td_api::Function> &&function) {
|
||||||
if (function == nullptr) {
|
if (function == nullptr) {
|
||||||
return td_api::make_object<td_api::error>(400, "Request is empty");
|
return td_api::make_object<td_api::error>(400, "Request is empty");
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace td {
|
|||||||
|
|
||||||
class SynchronousRequests {
|
class SynchronousRequests {
|
||||||
public:
|
public:
|
||||||
static td_api::object_ptr<td_api::Object> run_request(td_api::object_ptr<td_api::Function> function);
|
static td_api::object_ptr<td_api::Object> run_request(td_api::object_ptr<td_api::Function> &&function);
|
||||||
|
|
||||||
static bool is_synchronous_request(const td_api::Function *function);
|
static bool is_synchronous_request(const td_api::Function *function);
|
||||||
|
|
||||||
|
@ -2598,7 +2598,7 @@ void Td::request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
|||||||
run_request(id, std::move(function));
|
run_request(id, std::move(function));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::run_request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
void Td::run_request(uint64 id, td_api::object_ptr<td_api::Function> function) {
|
||||||
if (set_parameters_request_id_ > 0) {
|
if (set_parameters_request_id_ > 0) {
|
||||||
pending_set_parameters_requests_.emplace_back(id, std::move(function));
|
pending_set_parameters_requests_.emplace_back(id, std::move(function));
|
||||||
return;
|
return;
|
||||||
@ -2675,6 +2675,10 @@ void Td::run_request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
|||||||
!is_preinitialization_request(function_id) && !is_authentication_request(function_id)) {
|
!is_preinitialization_request(function_id) && !is_authentication_request(function_id)) {
|
||||||
return send_error_impl(id, make_error(401, "Unauthorized"));
|
return send_error_impl(id, make_error(401, "Unauthorized"));
|
||||||
}
|
}
|
||||||
|
do_run_request(id, std::move(function));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Td::do_run_request(uint64 id, td_api::object_ptr<td_api::Function> &&function) {
|
||||||
downcast_call(*function, [this, id](auto &request) { this->on_request(id, request); });
|
downcast_call(*function, [this, id](auto &request) { this->on_request(id, request); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3138,7 +3142,7 @@ template <class T>
|
|||||||
void Td::complete_pending_preauthentication_requests(const T &func) {
|
void Td::complete_pending_preauthentication_requests(const T &func) {
|
||||||
for (auto &request : pending_preauthentication_requests_) {
|
for (auto &request : pending_preauthentication_requests_) {
|
||||||
if (request.second != nullptr && func(request.second->get_id())) {
|
if (request.second != nullptr && func(request.second->get_id())) {
|
||||||
downcast_call(*request.second, [this, id = request.first](auto &request) { this->on_request(id, request); });
|
do_run_request(request.first, std::move(request.second));
|
||||||
request.second = nullptr;
|
request.second = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,9 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_connection_state_changed(ConnectionState new_state);
|
void on_connection_state_changed(ConnectionState new_state);
|
||||||
|
|
||||||
void run_request(uint64 id, tl_object_ptr<td_api::Function> function);
|
void run_request(uint64 id, td_api::object_ptr<td_api::Function> function);
|
||||||
|
|
||||||
|
void do_run_request(uint64 id, td_api::object_ptr<td_api::Function> &&function);
|
||||||
|
|
||||||
void send_result(uint64 id, tl_object_ptr<td_api::Object> object);
|
void send_result(uint64 id, tl_object_ptr<td_api::Object> object);
|
||||||
void send_error(uint64 id, Status error);
|
void send_error(uint64 id, Status error);
|
||||||
|
Loading…
Reference in New Issue
Block a user