diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-11-09 09:01:34 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-11-09 09:01:34 +0000 |
commit | 61e32f0ca35a86873c18fd619945b7255e5900da (patch) | |
tree | fa478ff642d32c3d9aa12e130d92a2a815c8f843 /protocols/VKontakte | |
parent | bc3a645445b09c80ddfb63c432e9968ebd1aea91 (diff) |
VKontakte: fix reconnect protocol after PollServer death
git-svn-id: http://svn.miranda-ng.org/main/trunk@10935 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 15 |
3 files changed, 17 insertions, 1 deletions
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 56b90c9dfa..5816c56bde 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -83,6 +83,7 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : // Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
+ m_iPollConnRetry = MAX_RETRIES;
vk_Instances.insert(this);
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 786bd082b6..f1d77e1be6 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -420,6 +420,8 @@ private: m_bStikersAsSmyles,
m_bUserForceOnlineOnActivity;
+ int m_iPollConnRetry;
+
enum MarkMsgReadOn{ markOnRead, markOnReceive, markOnReply, markOnTyping };
int m_iMarkMessageReadOn;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index a8b56f734d..5b899ca58c 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -75,6 +75,7 @@ void CVkProto::OnLoggedIn() {
debugLogA("CVkProto::OnLoggedIn");
m_bOnline = true;
+ m_iPollConnRetry = MAX_RETRIES;
SetServerStatus(m_iDesiredStatus);
// initialize online timer
@@ -978,10 +979,22 @@ int CVkProto::PollServer() debugLogA("CVkProto::PollServer is dead");
m_pollingConn = NULL;
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
- ShutdownSession();
+ if (m_iPollConnRetry){
+ m_iPollConnRetry--;
+ debugLogA("CVkProto::PollServer restarting %d", MAX_RETRIES - m_iPollConnRetry);
+ Sleep(1000);
+ PollServer();
+ }
+ else {
+ debugLogA("CVkProto::PollServer => ShutdownSession");
+ m_iPollConnRetry = MAX_RETRIES;
+ ShutdownSession();
+ }
return 0;
}
+ m_iPollConnRetry = MAX_RETRIES;
+
int retVal = 0;
if (reply->resultCode == 200) {
JSONROOT pRoot(reply->pData);
|