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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2022-02-05 21:28:43 +01:00
|
|
|
#include "td/telegram/ChainId.h"
|
2018-06-25 23:10:53 +02:00
|
|
|
#include "td/telegram/net/DcId.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/net/NetQuery.h"
|
2020-07-30 21:59:23 +02:00
|
|
|
#include "td/telegram/net/NetQueryStats.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/UniqueId.h"
|
|
|
|
|
2023-08-05 15:09:36 +02:00
|
|
|
#include "td/utils/common.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/ObjectPool.h"
|
|
|
|
|
2020-08-01 20:57:03 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
namespace td {
|
2018-04-24 18:21:47 +02:00
|
|
|
|
2020-03-15 23:01:14 +01:00
|
|
|
namespace telegram_api {
|
|
|
|
class Function;
|
|
|
|
} // namespace telegram_api
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
class NetQueryCreator {
|
|
|
|
public:
|
2021-10-06 17:47:32 +02:00
|
|
|
explicit NetQueryCreator(std::shared_ptr<NetQueryStats> net_query_stats);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void stop_check() {
|
|
|
|
object_pool_.set_check_empty(false);
|
|
|
|
}
|
|
|
|
|
2022-02-05 21:28:43 +01:00
|
|
|
NetQueryPtr create(const telegram_api::Function &function, vector<ChainId> chain_ids = {}, DcId dc_id = DcId::main(),
|
2020-03-15 23:01:14 +01:00
|
|
|
NetQuery::Type type = NetQuery::Type::Common);
|
2020-03-15 03:22:43 +01:00
|
|
|
|
2020-03-15 23:01:14 +01:00
|
|
|
NetQueryPtr create_unauth(const telegram_api::Function &function, DcId dc_id = DcId::main()) {
|
2024-03-07 16:37:28 +01:00
|
|
|
return create(UniqueId::next(), nullptr, function, {}, dc_id, NetQuery::Type::Common, NetQuery::AuthFlag::Off);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2020-03-15 02:15:54 +01:00
|
|
|
|
2024-03-07 16:37:28 +01:00
|
|
|
NetQueryPtr create_with_prefix(const unique_ptr<telegram_api::Function> &prefix,
|
|
|
|
const telegram_api::Function &function, DcId dc_id,
|
|
|
|
NetQuery::Type type = NetQuery::Type::Common);
|
|
|
|
|
|
|
|
NetQueryPtr create(uint64 id, const unique_ptr<telegram_api::Function> &prefix,
|
|
|
|
const telegram_api::Function &function, vector<ChainId> &&chain_ids, DcId dc_id,
|
2022-02-01 17:34:14 +01:00
|
|
|
NetQuery::Type type, NetQuery::AuthFlag auth_flag);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
private:
|
2020-07-30 16:28:56 +02:00
|
|
|
std::shared_ptr<NetQueryStats> net_query_stats_;
|
2018-12-31 20:04:05 +01:00
|
|
|
ObjectPool<NetQuery> object_pool_;
|
2023-07-26 11:29:36 +02:00
|
|
|
int32 current_scheduler_id_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
2018-04-24 18:21:47 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|