summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Telegram/src/mt_proto.h2
-rw-r--r--protocols/Telegram/src/server.cpp11
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<TD::chatListMain>(), 1000));
+ else {
+ m_impl.m_keepAlive.Start(1000);
+
+ SendQuery(new TD::getChats(td::tl::unique_ptr<TD::chatListMain>(), 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);
}