2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
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
|
|
|
|
|
|
|
|
#include "td/telegram/net/AuthDataShared.h"
|
|
|
|
#include "td/telegram/net/NetQuery.h"
|
|
|
|
|
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace td {
|
2018-04-24 18:21:47 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
class SessionProxy;
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SessionMultiProxy final : public Actor {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2023-01-14 22:25:22 +01:00
|
|
|
SessionMultiProxy(int32 session_count, std::shared_ptr<AuthDataShared> shared_auth_data, bool is_primary,
|
2023-10-23 13:05:50 +02:00
|
|
|
bool is_main, bool use_pfs, bool allow_media_only, bool is_media, bool is_cdn);
|
2023-05-05 12:51:19 +02:00
|
|
|
SessionMultiProxy(const SessionMultiProxy &) = delete;
|
|
|
|
SessionMultiProxy &operator=(const SessionMultiProxy &) = delete;
|
2021-07-03 22:51:36 +02:00
|
|
|
~SessionMultiProxy() final;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void send(NetQueryPtr query);
|
|
|
|
void update_main_flag(bool is_main);
|
|
|
|
|
|
|
|
void update_session_count(int32 session_count);
|
|
|
|
void update_use_pfs(bool use_pfs);
|
2023-10-23 13:58:12 +02:00
|
|
|
void update_options(int32 session_count, bool use_pfs, bool need_destroy_auth_key);
|
2018-05-10 20:02:24 +02:00
|
|
|
void update_mtproto_header();
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-10-23 13:00:22 +02:00
|
|
|
void destroy_auth_key();
|
2017-12-29 21:34:39 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
private:
|
|
|
|
int32 session_count_ = 0;
|
|
|
|
std::shared_ptr<AuthDataShared> auth_data_;
|
2023-01-14 22:25:22 +01:00
|
|
|
const bool is_primary_;
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_main_ = false;
|
|
|
|
bool use_pfs_ = false;
|
|
|
|
bool allow_media_only_ = false;
|
|
|
|
bool is_media_ = false;
|
|
|
|
bool is_cdn_ = false;
|
2017-12-29 21:34:39 +01:00
|
|
|
bool need_destroy_auth_key_ = false;
|
2019-03-15 10:00:18 +01:00
|
|
|
struct SessionInfo {
|
|
|
|
ActorOwn<SessionProxy> proxy;
|
2023-03-13 16:48:35 +01:00
|
|
|
int query_count{0};
|
2019-03-15 10:00:18 +01:00
|
|
|
};
|
|
|
|
uint32 sessions_generation_{0};
|
|
|
|
std::vector<SessionInfo> sessions_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void start_up() final;
|
2018-12-31 20:04:05 +01:00
|
|
|
void init();
|
|
|
|
|
|
|
|
bool get_pfs_flag() const;
|
|
|
|
|
2019-03-15 10:00:18 +01:00
|
|
|
void on_query_finished(uint32 generation, int session_id);
|
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
|