tdlight/td/telegram/ConnectionStateManager.cpp
Andrea Cavalli b6c5bd07bb Apply tdlight patch
- Memory manager
- TD_SKIP_TEST/TD_SKIP_BENCHMARK/TD_SKIP_TG_CLI
- Rebranding
- github workflow
- .gitignore
- Add crypt32 to windows
- Fatal crash log handler
- optionally unencrypted database
- malloc_trim support
- getMemoryStatistics

Options:
- disable_document_filenames
- disable_minithumbnails
- disable_notifications
- disable_group_calls
- disable_auto_download
- ignore_server_deletes_and_reads
- ignore_update_chat_last_message
- ignore_update_chat_read_inbox
- ignore_update_user_chat_action
- receive_access_hashes
- message_unload_delay modification
2024-08-27 15:24:01 +02:00

65 lines
1.9 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// 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)
//
#include "td/telegram/ConnectionStateManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/Td.h"
#include "td/utils/logging.h"
namespace td {
ConnectionStateManager::ConnectionStateManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
}
void ConnectionStateManager::tear_down() {
parent_.reset();
}
void ConnectionStateManager::start_up() {
class StateCallback final : public StateManager::Callback {
public:
explicit StateCallback(ActorId<ConnectionStateManager> parent) : parent_(std::move(parent)) {
}
bool on_state(ConnectionState state) final {
send_closure(parent_, &ConnectionStateManager::on_connection_state_changed, state);
return parent_.is_alive();
}
private:
ActorId<ConnectionStateManager> parent_;
};
send_closure(td_->state_manager_, &StateManager::add_callback, make_unique<StateCallback>(actor_id(this)));
}
void ConnectionStateManager::on_connection_state_changed(ConnectionState new_state) {
if (G()->close_flag()) {
return;
}
if (new_state == connection_state_) {
LOG(ERROR) << "State manager sent update about unchanged state " << static_cast<int32>(new_state);
return;
}
connection_state_ = new_state;
send_closure(G()->td(), &Td::send_update, get_update_connection_state_object(connection_state_));
}
void ConnectionStateManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
if (connection_state_ == ConnectionState::Empty) {
return;
}
updates.push_back(get_update_connection_state_object(connection_state_));
}
void ConnectionStateManager::memory_stats(vector<string> &output) {
}
} // namespace td