2018-12-31 20:04:05 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
//
|
|
|
|
#include "td/telegram/ClientActor.h"
|
|
|
|
|
|
|
|
#include "td/telegram/net/NetQueryCounter.h"
|
2020-07-30 16:28:56 +02:00
|
|
|
#include "td/telegram/net/NetQueryStats.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/Td.h"
|
|
|
|
|
|
|
|
namespace td {
|
2020-02-24 18:26:08 +01:00
|
|
|
|
2022-10-04 18:02:31 +02:00
|
|
|
ClientActor::ClientActor(unique_ptr<TdCallback> callback, Options options)
|
|
|
|
: callback_(std::move(callback)), options_(std::move(options)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClientActor::start_up() {
|
2020-07-30 16:28:56 +02:00
|
|
|
Td::Options td_options;
|
2022-10-04 18:02:31 +02:00
|
|
|
td_options.net_query_stats = std::move(options_.net_query_stats);
|
|
|
|
td_ = create_actor<Td>("Td", std::move(callback_), std::move(td_options));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClientActor::request(uint64 id, td_api::object_ptr<td_api::Function> request) {
|
2023-07-20 18:38:27 +02:00
|
|
|
send_closure_later(td_, &Td::request, id, std::move(request));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ClientActor::~ClientActor() = default;
|
|
|
|
|
2023-05-05 12:51:19 +02:00
|
|
|
ClientActor::ClientActor(ClientActor &&) noexcept = default;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-05 12:51:19 +02:00
|
|
|
ClientActor &ClientActor::operator=(ClientActor &&) noexcept = default;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
td_api::object_ptr<td_api::Object> ClientActor::execute(td_api::object_ptr<td_api::Function> request) {
|
|
|
|
return Td::static_request(std::move(request));
|
|
|
|
}
|
|
|
|
|
2020-07-30 16:28:56 +02:00
|
|
|
std::shared_ptr<NetQueryStats> create_net_query_stats() {
|
|
|
|
return std::make_shared<NetQueryStats>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dump_pending_network_queries(NetQueryStats &stats) {
|
|
|
|
stats.dump_pending_network_queries();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64 get_pending_network_query_count(NetQueryStats &stats) {
|
|
|
|
return stats.get_count();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|