2018-12-31 22:04:05 +03:00
|
|
|
//
|
2020-01-01 04:23:48 +03:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
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
|
|
|
|
|
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"
|
|
|
|
#include "td/telegram/UniqueId.h"
|
|
|
|
|
|
|
|
#include "td/utils/buffer.h"
|
|
|
|
#include "td/utils/ObjectPool.h"
|
|
|
|
|
|
|
|
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:
|
|
|
|
NetQueryCreator() {
|
|
|
|
object_pool_.set_check_empty(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void stop_check() {
|
|
|
|
object_pool_.set_check_empty(false);
|
|
|
|
}
|
|
|
|
|
2020-03-15 05:22:43 +03:00
|
|
|
NetQueryPtr create_update(BufferSlice &&buffer) {
|
2020-03-15 01:24:11 +03:00
|
|
|
return object_pool_.create(NetQuery::State::OK, 0, BufferSlice(), std::move(buffer), DcId::main(),
|
2020-03-16 04:09:17 +03:00
|
|
|
NetQuery::Type::Common, NetQuery::AuthFlag::On, NetQuery::GzipFlag::Off, 0, 0);
|
2018-12-31 22:04:05 +03:00
|
|
|
}
|
|
|
|
|
2020-03-16 01:01:14 +03:00
|
|
|
NetQueryPtr create(const telegram_api::Function &function, DcId dc_id = DcId::main(),
|
|
|
|
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()) {
|
|
|
|
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
|
|
|
|
2020-03-16 01:01:14 +03:00
|
|
|
NetQueryPtr create(uint64 id, const telegram_api::Function &function, DcId dc_id, NetQuery::Type type,
|
|
|
|
NetQuery::AuthFlag auth_flag);
|
2018-12-31 22:04:05 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
ObjectPool<NetQuery> object_pool_;
|
|
|
|
};
|
2018-04-24 19:21:47 +03:00
|
|
|
|
2018-12-31 22:04:05 +03:00
|
|
|
} // namespace td
|