2018-12-31 20:04:05 +01:00
|
|
|
//
|
2021-01-01 13:57:46 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
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
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
#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);
|
|
|
|
}
|
|
|
|
|
2020-03-15 23:01:14 +01:00
|
|
|
NetQueryPtr create(const telegram_api::Function &function, DcId dc_id = DcId::main(),
|
|
|
|
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()) {
|
|
|
|
return create(UniqueId::next(), 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
|
|
|
|
2020-03-15 23:01:14 +01:00
|
|
|
NetQueryPtr create(uint64 id, const telegram_api::Function &function, DcId dc_id, 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_;
|
|
|
|
};
|
2018-04-24 18:21:47 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|