diff options
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 31 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 4 |
4 files changed, 29 insertions, 11 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 889fc82466..3b420618bc 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 2
-#define __BUILD_NUM 14
+#define __BUILD_NUM 15
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 8d4dcac8fd..ec1e9e53a7 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -115,11 +115,12 @@ void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int NDay) void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int iTime, int iLastMsgId, bool once)
{
- debugLogA("CVkProto::GetServerHistory %d %d %d %d %d", iOffset, iCount, iTime, iLastMsgId, (int)once);
+ debugLogA("CVkProto::GetServerHistory");
if (!IsOnline() || iCount == 0)
return;
LONG userID = getDword(hContact, "ID", VK_INVALID_USER);
+ debugLogA("CVkProto::GetServerHistory %ld %d %d %d %d %d", userID, iOffset, iCount, iTime, iLastMsgId, (int)once);
if (VK_INVALID_USER == userID || userID == VK_FEED_USER)
return;
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index d23c68e995..ba844d1436 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -151,7 +151,9 @@ void CVkProto::WorkerThread(void*) break;
AsyncHttpRequest *pReq;
- bool need_sleep = false;
+ ULONG uTime[3] = { 0, 0, 0 };
+ long lWaitingTime = 0;
+
while (true) {
{
mir_cslock lck(m_csRequestsQueue);
@@ -160,15 +162,30 @@ void CVkProto::WorkerThread(void*) pReq = m_arRequestsQueue[0];
m_arRequestsQueue.remove(0);
- need_sleep = (m_arRequestsQueue.getCount() > 1) && (pReq->m_bApiReq); // more than two to not gather
+
+ ULONG utime = GetTickCount();
+ lWaitingTime = (utime - uTime[0]) > 1000 ? 0 : 1100 - (utime - uTime[0]);
+
+ if (!(pReq->m_bApiReq) || lWaitingTime < 0)
+ lWaitingTime = 0;
}
+
if (m_bTerminated)
break;
- ExecuteRequest(pReq);
- if (need_sleep) { // There can be maximum 3 requests to API methods per second from a client
- Sleep(800); // (c) https://vk.com/dev/api_requests
- debugLogA("CVkProto::WorkerThread: need sleep");
+
+ if (lWaitingTime) {
+ debugLogA("CVkProto::WorkerThread: need sleep %d msec", lWaitingTime);
+ Sleep(lWaitingTime);
+ }
+
+ if (pReq->m_bApiReq) {
+ uTime[0] = uTime[1];
+ uTime[1] = uTime[2];
+ uTime[2] = GetTickCount();
+ // There can be maximum 3 requests to API methods per second from a client
+ // see https://vk.com/dev/api_requests
}
+ ExecuteRequest(pReq);
}
}
@@ -190,7 +207,7 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const INT_PARAM ¶m) CMStringA &s = pReq->m_szParam;
if (!s.IsEmpty())
s.AppendChar('&');
- s.AppendFormat("%s=%i", param.szName, param.iValue);
+ s.AppendFormat("%s=%ld", param.szName, param.iValue);
return pReq;
}
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 9b2e05766a..7b94c9e461 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -54,8 +54,8 @@ struct PARAM struct INT_PARAM : public PARAM
{
- int iValue;
- __forceinline INT_PARAM(LPCSTR _name, int _value) :
+ long iValue;
+ __forceinline INT_PARAM(LPCSTR _name, long _value) :
PARAM(_name), iValue(_value)
{}
};
|