summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-09-12 04:12:46 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-09-12 04:12:46 +0000
commit4eb09f2d68b16951f2a3ff848bdf20ab6566170f (patch)
tree382efdf45b1a6e3a1e222f7d8a442459d0735b9a
parent7af293e22654f3687da6cc6df9a01f58ce0b7fce (diff)
VKontakte:
fix for view chat messages in chatlog global fix for ‘Too many requests per second’ error git-svn-id: http://svn.miranda-ng.org/main/trunk@10435 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp2
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index a60cc2fc31..63df8015fe 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -365,8 +365,6 @@ void CVkProto::OnSendChatMsg(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
if (reply->resultCode == 200) {
JSONROOT pRoot;
JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
- if (pResponse != NULL)
- m_sendIds.insert((void*)json_as_int(pResponse));
}
}
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index bb506bd0ce..c1934fa190 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -103,6 +103,7 @@ void CVkProto::WorkerThread(void*)
break;
AsyncHttpRequest *pReq;
+ bool need_sleep = false;
while(true) {
{
mir_cslock lck(m_csRequestsQueue);
@@ -111,8 +112,11 @@ void CVkProto::WorkerThread(void*)
pReq = m_arRequestsQueue[0];
m_arRequestsQueue.remove(0);
+ need_sleep = (m_arRequestsQueue.getCount() > 1); // more than two to not gather
}
ExecuteRequest(pReq);
+ if (need_sleep) // There can be maximum 3 requests to API methods per second from a client
+ Sleep(330); // (c) https://vk.com/dev/api_requests
}
}