From cf379ef3c47b386c970d7d0f8724f85abcbff8cc Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 2 May 2015 14:34:42 +0000 Subject: SkypeWeb: Polling refactoring. Small fix. git-svn-id: http://svn.miranda-ng.org/main/trunk@13374 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_polling.cpp | 46 +++++++++++++++++++------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_polling.cpp') diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp index 5c069c06a4..df80efc787 100644 --- a/protocols/SkypeWeb/src/skype_polling.cpp +++ b/protocols/SkypeWeb/src/skype_polling.cpp @@ -73,33 +73,41 @@ void CSkypeProto::PollingThread(void*) continue; } - if (response->resultCode != 200) + if (response->resultCode == 200) { - errors++; + if (response->pData) + { + JSONROOT root(response->pData); + JSONNODE *events = json_get(root, "eventMessages"); + if (events != NULL) + { + ParsePollData(root); + } + } } - - if (response->pData) + else { - JSONROOT root(response->pData); - JSONNODE *eventMsgs = json_get(root, "eventMessages"); - JSONNODE *errorCode = json_get(root, "errorCode"); - - if (eventMsgs != NULL) - ParsePollData(root); + errors++; - else if (errorCode != NULL) + if (response->pData) { - errors++; - debugLogA(__FUNCTION__": polling error %d", json_as_int(errorCode)); - if (json_as_int(errorCode) == 729) + JSONROOT root(response->pData); + JSONNODE *error = json_get(root, "errorCode"); + if (error != NULL) { - SendRequest(new CreateEndpointRequest(TokenSecret), &CSkypeProto::OnEndpointCreated); - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response); - delete request; - break; - } + int errorCode = json_as_int(error); + + if (errorCode == 729) + { + SendRequest(new CreateEndpointRequest(TokenSecret), &CSkypeProto::OnEndpointCreated); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response); + delete request; + break; + } + } } } + m_pollingConnection = response->nlc; CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response); delete request; -- cgit v1.2.3