summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_polling.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-08-14 11:04:04 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-08-14 11:04:04 +0000
commitebc91d7be8f31d98822b896852e40c341b614a48 (patch)
treeaef84f69b879aa35bbe5fc3e6cc079900ecb3b22 /protocols/SkypeWeb/src/skype_polling.cpp
parent3ec93b6744328421a82b9fd39d711eeea0d9749a (diff)
SkypeWeb: Async polling processing, more optimizations
git-svn-id: http://svn.miranda-ng.org/main/trunk@14951 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_polling.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
index 612547b1ee..b1b91a8d6f 100644
--- a/protocols/SkypeWeb/src/skype_polling.cpp
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -17,39 +17,40 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-void CSkypeProto::ParsePollData(const JSONNode &data)
+void CSkypeProto::ParsePollData(void *pData)
{
debugLogA("CSkypeProto::ParsePollData");
+ JSONNode data = JSONNode::parse(ptrA((char*)pData));
+ if (!data) return;
+
const JSONNode &node = data["eventMessages"];
- if (!node)
- return;
+ if (!node) return;
- const JSONNode &messages = node.as_array();
- for (size_t i = 0; i < messages.size(); i++)
+ for (auto it = node.begin(); it != node.end(); ++it)
{
- const JSONNode &message = messages.at(i);
+ const JSONNode &message = *it;
const JSONNode &resType = message["resourceType"];
const JSONNode &resource = message["resource"];
std::string resourceType = resType.as_string();
- if (!mir_strcmpi(resourceType.c_str(), "NewMessage"))
+ if (resourceType == "NewMessage")
{
ProcessNewMessageRes(resource);
}
- else if (!mir_strcmpi(resourceType.c_str(), "UserPresence"))
+ else if (resourceType == "UserPresence")
{
ProcessUserPresenceRes(resource);
}
- else if (!mir_strcmpi(resourceType.c_str(), "EndpointPresence"))
+ else if (resourceType == "EndpointPresence")
{
ProcessEndpointPresenceRes(resource);
}
- else if (!mir_strcmpi(resourceType.c_str(), "ConversationUpdate"))
+ else if (resourceType == "ConversationUpdate")
{
ProcessConversationUpdateRes(resource);
}
- else if (!mir_strcmpi(resourceType.c_str(), "ThreadUpdate"))
+ else if (resourceType == "ThreadUpdate")
{
ProcessThreadUpdateRes(resource);
}
@@ -79,11 +80,9 @@ void CSkypeProto::PollingThread(void*)
{
if (response->pData)
{
- JSONNode root = JSONNode::parse(response->pData);
- if (root["eventMessages"])
- {
- ParsePollData(root);
- }
+ void *pData = mir_alloc(response->dataLength);
+ memcpy(pData, response->pData, response->dataLength);
+ ForkThread(&CSkypeProto::ParsePollData, pData);
}
}
else