From 0c601c9ac661bd86975d1d408908c94e61b2fe33 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 15 Jan 2023 15:46:13 +0300 Subject: =?UTF-8?q?fixes=20#3307=20(Telegram:=20=D0=BA=D0=BE=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D1=8B=20=D1=87=D0=B0=D1=81=D1=82=D0=BE=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BB=D0=B8=D0=BF=D0=B0=D1=8E=D1=82=20=D0=B2=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=D0=B5=20Away)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/mt_proto.h | 2 ++ protocols/Telegram/src/server.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/protocols/Telegram/src/mt_proto.h b/protocols/Telegram/src/mt_proto.h index bf5c9e667b..9ab923de87 100644 --- a/protocols/Telegram/src/mt_proto.h +++ b/protocols/Telegram/src/mt_proto.h @@ -1,5 +1,7 @@ #pragma once +#define STATUS_SWITCH_TIMEOUT 600 + #define DBKEY_ID "id" #define DBKEY_AVATAR_HASH "AvatarHash" diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 5828478802..2f40be0871 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -50,6 +50,7 @@ void CMTProto::LogOut() ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; + m_impl.m_keepAlive.Stop(); setAllContactStatuses(ID_STATUS_OFFLINE, false); } @@ -66,7 +67,11 @@ void CMTProto::OnLoggedIn() SendQuery(new TD::terminateSession()); SendQuery(new TD::logOut(), &CMTProto::OnEndSession); } - else SendQuery(new TD::getChats(td::tl::unique_ptr(), 1000)); + else { + m_impl.m_keepAlive.Start(1000); + + SendQuery(new TD::getChats(td::tl::unique_ptr(), 1000)); + } } /////////////////////////////////////////////////////////////////////////////// @@ -76,12 +81,12 @@ void CMTProto::SendKeepAlive() time_t now = time(0); for (auto &it : m_arUsers) { - if (it->m_timer1 && now - it->m_timer1 > 600) { + if (it->m_timer1 && now - it->m_timer1 > STATUS_SWITCH_TIMEOUT) { it->m_timer1 = 0; it->m_timer2 = now; setWord(it->hContact, "Status", ID_STATUS_AWAY); } - else if (it->m_timer2 && now - it->m_timer2 > 600) { + else if (it->m_timer2 && now - it->m_timer2 > STATUS_SWITCH_TIMEOUT) { it->m_timer2 = 0; setWord(it->hContact, "Status", ID_STATUS_OFFLINE); } -- cgit v1.2.3