Init sessions if there are multiple sessions.
This commit is contained in:
parent
a9712d7afa
commit
1669f8d4b8
@ -29,6 +29,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/TopDialogManager.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
|
||||
#include "td/db/KeyValueSyncInterface.h"
|
||||
#include "td/db/TsSeqKeyValue.h"
|
||||
@ -450,6 +451,7 @@ void OptionManager::on_option_updated(Slice name) {
|
||||
}
|
||||
if (name == "session_count") {
|
||||
G()->net_query_dispatcher().update_session_count();
|
||||
td_->updates_manager_->init_sessions(false);
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
|
@ -156,6 +156,19 @@ class PingServerQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class InitSessionQuery final : public Td::ResultHandler {
|
||||
public:
|
||||
void send() {
|
||||
send_query(G()->net_query_creator().create(telegram_api::help_getCdnConfig()));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice) final {
|
||||
}
|
||||
|
||||
void on_error(Status) final {
|
||||
}
|
||||
};
|
||||
|
||||
class GetDifferenceQuery final : public Td::ResultHandler {
|
||||
Promise<tl_object_ptr<telegram_api::updates_Difference>> promise_;
|
||||
|
||||
@ -1732,6 +1745,26 @@ void UpdatesManager::on_server_pong(tl_object_ptr<telegram_api::updates_state> &
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatesManager::init_sessions(bool is_first) {
|
||||
if (G()->close_flag()) {
|
||||
return;
|
||||
}
|
||||
if (are_sessions_inited_ == is_first || !td_->auth_manager_->is_authorized()) {
|
||||
return;
|
||||
}
|
||||
are_sessions_inited_ = true;
|
||||
|
||||
auto session_count = td_->option_manager_->get_option_integer("session_count", 1);
|
||||
if (session_count <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Init " << session_count << " sessions";
|
||||
for (size_t i = 0; i < session_count; i++) {
|
||||
td_->create_handler<InitSessionQuery>()->send();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatesManager::process_get_difference_updates(
|
||||
vector<tl_object_ptr<telegram_api::Message>> &&new_messages,
|
||||
vector<tl_object_ptr<telegram_api::EncryptedMessage>> &&new_encrypted_messages,
|
||||
@ -2097,6 +2130,8 @@ void UpdatesManager::after_get_difference() {
|
||||
send_closure(G()->state_manager(), &StateManager::on_synchronized, true);
|
||||
get_difference_start_time_ = 0.0;
|
||||
|
||||
init_sessions(true);
|
||||
|
||||
try_reload_data();
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,8 @@ class UpdatesManager final : public Actor {
|
||||
|
||||
void ping_server();
|
||||
|
||||
void init_sessions(bool is_first);
|
||||
|
||||
bool running_get_difference() const {
|
||||
return running_get_difference_;
|
||||
}
|
||||
@ -258,6 +260,8 @@ class UpdatesManager final : public Actor {
|
||||
|
||||
bool is_ping_sent_ = false;
|
||||
|
||||
bool are_sessions_inited_ = false;
|
||||
|
||||
bool running_get_difference_ = false;
|
||||
bool finished_first_get_difference_ = false;
|
||||
int32 last_confirmed_pts_ = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user