Client improvements.
GitOrigin-RevId: 85b45a31fbb7b7b84a87d3951086332d750de01c
This commit is contained in:
parent
5ee113439f
commit
03a11bc2ec
@ -53,7 +53,7 @@ namespace td_api = td::td_api;
|
||||
class TdExample {
|
||||
public:
|
||||
TdExample() {
|
||||
td::Log::set_verbosity_level(10);
|
||||
td::Log::set_verbosity_level(1);
|
||||
client_ = std::make_unique<td::Client>();
|
||||
}
|
||||
|
||||
@ -87,6 +87,9 @@ class TdExample {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (action == "close") {
|
||||
std::cerr << "Closing..." << std::endl;
|
||||
send_query(td_api::make_object<td_api::close>(), {});
|
||||
} else if (action == "l") {
|
||||
std::cerr << "Logging out..." << std::endl;
|
||||
send_query(td_api::make_object<td_api::logOut>(), {});
|
||||
|
@ -29,11 +29,6 @@ class Client::Impl final {
|
||||
}
|
||||
|
||||
void send(Request request) {
|
||||
if (request.id == 0 || request.function == nullptr) {
|
||||
LOG(ERROR) << "Drop wrong request " << request.id;
|
||||
return;
|
||||
}
|
||||
|
||||
requests_.push_back(std::move(request));
|
||||
}
|
||||
|
||||
@ -160,7 +155,7 @@ class Client::Impl final {
|
||||
scheduler_->init(3);
|
||||
class Callback : public TdCallback {
|
||||
public:
|
||||
Callback(std::shared_ptr<OutputQueue> output_queue) : output_queue_(std::move(output_queue)) {
|
||||
explicit Callback(std::shared_ptr<OutputQueue> output_queue) : output_queue_(std::move(output_queue)) {
|
||||
}
|
||||
void on_result(std::uint64_t id, td_api::object_ptr<td_api::Object> result) override {
|
||||
output_queue_->writer_put({id, std::move(result)});
|
||||
|
@ -3292,12 +3292,12 @@ bool Td::is_preauthentication_request(int32 id) {
|
||||
}
|
||||
|
||||
void Td::request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
||||
request_set_.insert(id);
|
||||
|
||||
if (id == 0) {
|
||||
LOG(ERROR) << "Receive request with id == 0";
|
||||
return send_error_raw(id, 400, "Wrong request id == 0");
|
||||
LOG(ERROR) << "Ignore request with id == 0: " << to_string(function);
|
||||
return;
|
||||
}
|
||||
|
||||
request_set_.insert(id);
|
||||
if (function == nullptr) {
|
||||
LOG(ERROR) << "Receive empty request";
|
||||
return send_error_raw(id, 400, "Request is empty");
|
||||
|
Reference in New Issue
Block a user