aboutsummaryrefslogtreecommitdiffhomepage
path: root/td/telegram/ClientActor.cpp
blob: b3efe17c0670b0249a8adebc921e2e2a4128546d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// 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"
#include "td/telegram/net/NetQueryStats.h"
#include "td/telegram/Td.h"

namespace td {

ClientActor::ClientActor(unique_ptr<TdCallback> callback, Options options)
    : callback_(std::move(callback)), options_(std::move(options)) {
}

void ClientActor::start_up() {
  Td::Options td_options;
  td_options.net_query_stats = std::move(options_.net_query_stats);
  td_ = create_actor<Td>("Td", std::move(callback_), std::move(td_options));
}

void ClientActor::request(uint64 id, td_api::object_ptr<td_api::Function> request) {
  send_closure(td_, &Td::request, id, std::move(request));
}

ClientActor::~ClientActor() = default;

ClientActor::ClientActor(ClientActor &&other) noexcept = default;

ClientActor &ClientActor::operator=(ClientActor &&other) noexcept = default;

td_api::object_ptr<td_api::Object> ClientActor::execute(td_api::object_ptr<td_api::Function> request) {
  return Td::static_request(std::move(request));
}

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();
}

}  // namespace td