Use online_update_period_ms option.

GitOrigin-RevId: 8354e248ff424d4bed7eb474521bdd2c9685f522
This commit is contained in:
levlam 2018-11-08 16:06:17 +03:00
parent a3049fa4b4
commit be92820691
3 changed files with 8 additions and 6 deletions

View File

@ -854,6 +854,9 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
shared_config.set_option_string("photo_search_bot_username", config->img_search_username_);
}
shared_config.set_option_integer("online_update_period_ms", config->online_update_period_ms_);
shared_config.set_option_integer("online_cloud_timeout_ms", config->online_cloud_timeout_ms_);
// delete outdated options
shared_config.set_option_empty("suggested_language_code");
shared_config.set_option_empty("chat_big_size");
@ -865,10 +868,8 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
shared_config.set_option_empty("group_chat_size_max");
shared_config.set_option_empty("chat_size_max");
shared_config.set_option_empty("megagroup_size_max");
shared_config.set_option_empty("online_update_period_ms");
shared_config.set_option_empty("offline_blur_timeout_ms");
shared_config.set_option_empty("offline_idle_timeout_ms");
shared_config.set_option_empty("online_cloud_timeout_ms");
shared_config.set_option_empty("notify_cloud_delay_ms");
shared_config.set_option_empty("notify_default_delay_ms");
shared_config.set_option_empty("large_chat_size");
@ -880,10 +881,9 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
}
// TODO implement online status updates
// shared_config.set_option_integer("online_update_period_ms", config->online_update_period_ms_);
// shared_config.set_option_integer("offline_blur_timeout_ms", config->offline_blur_timeout_ms_);
// shared_config.set_option_integer("offline_idle_timeout_ms", config->offline_idle_timeout_ms_);
// shared_config.set_option_integer("online_cloud_timeout_ms", config->online_cloud_timeout_ms_);
// shared_config.set_option_integer("notify_cloud_delay_ms", config->notify_cloud_delay_ms_);
// shared_config.set_option_integer("notify_default_delay_ms", config->notify_default_delay_ms_);

View File

@ -3021,7 +3021,8 @@ void Td::on_online_updated(bool force, bool send_update) {
update_status_query_ = create_handler<UpdateStatusQuery>()->send(!is_online_);
}
if (is_online_) {
alarm_timeout_.set_timeout_in(ONLINE_ALARM_ID, ONLINE_TIMEOUT);
alarm_timeout_.set_timeout_in(ONLINE_ALARM_ID,
G()->shared_config().get_option_integer("online_update_period_ms", 120000) * 1e-3);
} else {
alarm_timeout_.cancel_timeout(ONLINE_ALARM_ID);
}
@ -3422,6 +3423,8 @@ bool Td::is_internal_config_option(Slice name) {
return name == "language_pack_version";
case 'm':
return name == "my_phone_number";
case 'o':
return name == "online_update_period_ms" || name == "online_cloud_timeout_ms";
case 'r':
return name == "revoke_pm_inbox" || name == "revoke_time_limit" || name == "revoke_pm_time_limit" ||
name == "rating_e_decay" || name == "recent_stickers_limit";

View File

@ -206,7 +206,6 @@ class Td final : public NetQueryCallback {
private:
static constexpr const char *TDLIB_VERSION = "1.3.3";
static constexpr int64 ONLINE_ALARM_ID = 0;
static constexpr int32 ONLINE_TIMEOUT = 240;
static constexpr int64 PING_SERVER_ALARM_ID = -1;
static constexpr int32 PING_SERVER_TIMEOUT = 300;
static constexpr int64 TERMS_OF_SERVICE_ALARM_ID = -2;