diff options
Diffstat (limited to 'protocols')
-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 | 59 |
3 files changed, 24 insertions, 38 deletions
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 5816c56bde..56b90c9dfa 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -83,7 +83,6 @@ 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 f1d77e1be6..786bd082b6 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -420,8 +420,6 @@ 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 c480b74cc8..8a9653affc 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -75,7 +75,6 @@ void CVkProto::OnLoggedIn() {
debugLogA("CVkProto::OnLoggedIn");
m_bOnline = true;
- m_iPollConnRetry = MAX_RETRIES;
SetServerStatus(m_iDesiredStatus);
// initialize online timer
@@ -961,49 +960,39 @@ int CVkProto::PollServer() if (!IsOnline()){
debugLogA("CVkProto::PollServer is dead (not online)");
m_pollingConn = NULL;
- 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();
- }
+ ShutdownSession();
return 0;
}
debugLogA("CVkProto::PollServer (online)");
- NETLIBHTTPREQUEST req = { sizeof(req) };
- req.requestType = REQUEST_GET;
- req.szUrl = NEWSTR_ALLOCA(CMStringA().Format("http://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s&mode=%d", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken, 106));
- // see mode parametr description on https://vk.com/dev/using_longpoll (Russian version)
- req.flags = VK_NODUMPHEADERS | NLHRF_PERSISTENT;
- req.timeout = 30000;
- req.nlc = m_pollingConn;
-
- NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
- if (reply == NULL) {
- debugLogA("CVkProto::PollServer is dead");
+ int iPollConnRetry = MAX_RETRIES;
+ NETLIBHTTPREQUEST *reply;
+ do {
+ NETLIBHTTPREQUEST req = { sizeof(req) };
+ req.requestType = REQUEST_GET;
+ req.szUrl = NEWSTR_ALLOCA(CMStringA().Format("http://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s&mode=%d", m_pollingServer, m_pollingKey, m_pollingTs, m_szAccessToken, 106));
+ // see mode parametr description on https://vk.com/dev/using_longpoll (Russian version)
+ req.flags = VK_NODUMPHEADERS | NLHRF_PERSISTENT;
+ req.timeout = 30000;
+ req.nlc = m_pollingConn;
+
+ reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)&req);
+ if (reply != NULL)
+ break;
+ debugLogA("CVkProto::PollServer is dead");
m_pollingConn = NULL;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply);
- if (m_iPollConnRetry){
- m_iPollConnRetry--;
- debugLogA("CVkProto::PollServer restarting %d", MAX_RETRIES - m_iPollConnRetry);
- Sleep(1000);
- PollServer();
+ if (iPollConnRetry){
+ iPollConnRetry--;
+ debugLogA("CVkProto::PollServer restarting %d", MAX_RETRIES - iPollConnRetry);
+ Sleep(1000);
}
else {
debugLogA("CVkProto::PollServer => ShutdownSession");
- m_iPollConnRetry = MAX_RETRIES;
ShutdownSession();
- }
- return 0;
- }
-
- m_iPollConnRetry = MAX_RETRIES;
+ return 0;
+ }
+ } while (true);
+
int retVal = 0;
if (reply->resultCode == 200) {
|