2018-12-31 22:04:05 +03:00
|
|
|
//
|
2022-01-01 03:35:39 +03:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
2018-12-31 22:04:05 +03: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 23:28:43 +03:00
|
|
|
#include "td/telegram/ChainId.h"
|
2018-06-26 00:10:53 +03:00
|
|
|
#include "td/telegram/net/DcId.h"
|
2018-12-31 22:04:05 +03:00
|
|
|
#include "td/telegram/net/NetQuery.h"
|
2020-07-30 22:59:23 +03:00
|
|
|
#include "td/telegram/net/NetQueryStats.h"
|
2018-12-31 22:04:05 +03:00
|
|
|
#include "td/telegram/UniqueId.h"
|
|
|
|
|
|
|
|
#include "td/utils/ObjectPool.h"
|
|
|
|
|
2020-08-01 21:57:03 +03:00
|
|
|
#include <memory>
|
|
|
|
|
2018-12-31 22:04:05 +03:00
|
|
|
namespace td {
|
2018-04-24 19:21:47 +03:00
|
|
|
|
2020-03-16 01:01:14 +03:00
|
|
|
namespace telegram_api {
|
|
|
|
class Function;
|
|
|
|
} // namespace telegram_api
|
|
|
|
|
2018-12-31 22:04:05 +03:00
|
|
|
class NetQueryCreator {
|
|
|
|
public:
|
2021-10-06 18:47:32 +03:00
|
|
|
explicit NetQueryCreator(std::shared_ptr<NetQueryStats> net_query_stats);
|
2018-12-31 22:04:05 +03:00
|
|
|
|
|
|
|
void stop_check() {
|
|
|
|
object_pool_.set_check_empty(false);
|
|
|
|
}
|
|
|
|
|
2022-02-05 23:28:43 +03:00
|
|
|
NetQueryPtr create(const telegram_api::Function &function, vector<ChainId> chain_ids = {}, DcId dc_id = DcId::main(),
|
2020-03-16 01:01:14 +03:00
|
|
|
NetQuery::Type type = NetQuery::Type::Common);
|
2020-03-15 05:22:43 +03:00
|
|
|
|
2020-03-16 01:01:14 +03:00
|
|
|
NetQueryPtr create_unauth(const telegram_api::Function &function, DcId dc_id = DcId::main()) {
|
2022-02-01 18:51:20 +03:00
|
|
|
return create(UniqueId::next(), function, {}, dc_id, NetQuery::Type::Common, NetQuery::AuthFlag::Off);
|
2018-12-31 22:04:05 +03:00
|
|
|
}
|
2020-03-15 04:15:54 +03:00
|
|
|
|
2022-02-05 23:28:43 +03:00
|
|
|
NetQueryPtr create(uint64 id, const telegram_api::Function &function, vector<ChainId> &&chain_ids, DcId dc_id,
|
2022-02-01 19:34:14 +03:00
|
|
|
NetQuery::Type type, NetQuery::AuthFlag auth_flag);
|
2018-12-31 22:04:05 +03:00
|
|
|
|
|
|
|
private:
|
2020-07-30 17:28:56 +03:00
|
|
|
std::shared_ptr<NetQueryStats> net_query_stats_;
|
2018-12-31 22:04:05 +03:00
|
|
|
ObjectPool<NetQuery> object_pool_;
|
|
|
|
};
|
2018-04-24 19:21:47 +03:00
|
|
|
|
2018-12-31 22:04:05 +03:00
|
|
|
} // namespace td
|