summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/td/telegram/OnlineManager.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-29 19:03:55 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-29 19:04:03 +0300
commitcebfc5c8facbf6ae335499f7f4b3dc57a60af999 (patch)
tree4c39e613c87f6164df1fe80601e611987aaaec84 /protocols/Telegram/tdlib/td/td/telegram/OnlineManager.h
parent189164bebda4bca9bb3d672500d844bfe7f26517 (diff)
TDLIB update up to the current state
Diffstat (limited to 'protocols/Telegram/tdlib/td/td/telegram/OnlineManager.h')
-rw-r--r--protocols/Telegram/tdlib/td/td/telegram/OnlineManager.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/protocols/Telegram/tdlib/td/td/telegram/OnlineManager.h b/protocols/Telegram/tdlib/td/td/telegram/OnlineManager.h
new file mode 100644
index 0000000000..fda4803e8a
--- /dev/null
+++ b/protocols/Telegram/tdlib/td/td/telegram/OnlineManager.h
@@ -0,0 +1,60 @@
+//
+// 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)
+//
+#pragma once
+
+#include "td/telegram/net/NetQuery.h"
+
+#include "td/actor/actor.h"
+#include "td/actor/Timeout.h"
+
+#include "td/utils/common.h"
+
+namespace td {
+
+class Td;
+
+class OnlineManager final : public Actor {
+ public:
+ OnlineManager(Td *td, ActorShared<> parent);
+
+ void init();
+
+ void on_online_updated(bool force, bool send_update);
+
+ void on_update_status_success(bool is_online);
+
+ bool is_online() const;
+
+ void set_is_online(bool is_online);
+
+ void set_is_bot_online(bool is_bot_online);
+
+ private:
+ static constexpr int32 PING_SERVER_TIMEOUT = 300;
+
+ void tear_down() final;
+
+ void start_up() final;
+
+ static void on_online_timeout_callback(void *online_manager_ptr);
+
+ static void on_ping_server_timeout_callback(void *online_manager_ptr);
+
+ void on_ping_server_timeout();
+
+ Td *td_;
+ ActorShared<> parent_;
+
+ bool is_online_ = false;
+ bool is_bot_online_ = false;
+ NetQueryRef update_status_query_;
+
+ Timeout online_timeout_;
+ Timeout ping_server_timeout_;
+};
+
+} // namespace td