summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_proto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-12 22:33:13 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-12 22:33:13 +0000
commit32d1c295ac763fdf069ac6915d772c0b92818fc4 (patch)
tree1f2d34d2bdfaa4f22bb0b344e4028489ce07cca8 /protocols/VKontakte/src/vk_proto.cpp
parent7d8f746129a286b6c0488e461811c25da40f60c0 (diff)
VK:
- notification thread now works as expected; - message reading works ok too; - notification about new messages also works ok git-svn-id: http://svn.miranda-ng.org/main/trunk@6467 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_proto.cpp')
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 2ef53906ea..07740f4725 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
PROTO<CVkProto>(szModuleName, ptszUserName),
m_arRequestsQueue(10),
+ m_sendIds(3, PtrKeySortT),
m_msgId(1)
{
InitQueue();
@@ -146,13 +147,28 @@ int CVkProto::SendMsg(HANDLE hContact, int flags, const char *msg)
{ "message", szMsg },
{ "access_token", m_szAccessToken }
};
- PushAsyncHttpRequest(REQUEST_GET, "/method/messages.send.json", true, NULL, SIZEOF(params), params);
+ PushAsyncHttpRequest(REQUEST_GET, "/method/messages.send.json", true, &CVkProto::OnSendMessage, SIZEOF(params), params);
ULONG msgId = ::InterlockedIncrement(&m_msgId);
ForkThread(&CVkProto::SendMsgAck, new TFakeAckParams(hContact, msgId));
return msgId;
}
+void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, void*)
+{
+ debugLogA("CVkProto::OnSendMessage %d", reply->resultCode);
+ if (reply->resultCode != 200)
+ return;
+
+ JSONROOT pRoot(reply->pData);
+ if ( !CheckJsonResult(pRoot))
+ return;
+
+ JSONNODE *pResponse = json_get(pRoot, "response");
+ if (pResponse != NULL)
+ m_sendIds.insert((HANDLE)json_as_int(pResponse));
+}
+
//////////////////////////////////////////////////////////////////////////////
int CVkProto::SetStatus(int iNewStatus)