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_trouter.cpp | 50 +++++++++++++++----------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_trouter.cpp') diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp index 854a4e75d7..0f22c3d98f 100644 --- a/protocols/SkypeWeb/src/skype_trouter.cpp +++ b/protocols/SkypeWeb/src/skype_trouter.cpp @@ -72,7 +72,7 @@ void CSkypeProto::OnGetTrouter(const NETLIBHTTPREQUEST *response) CMStringA szToken = data.Tokenize(":", iStart).Trim(); setString("Trouter_SessId", szToken); m_hTrouterThread = ForkThreadEx(&CSkypeProto::TRouterThread, 0, NULL); - SendRequest(new RegisterTrouterRequest(TokenSecret, ptrA(getStringA("Trouter_url")))); + SendRequest(new RegisterTrouterRequest(TokenSecret, ptrA(getStringA("Trouter_url")), szToken)); } void CSkypeProto::OnHealth(const NETLIBHTTPREQUEST*) @@ -158,34 +158,32 @@ void CSkypeProto::TRouterThread(void*) request->nlc = m_TrouterConnection; NETLIBHTTPREQUEST *response = request->Send(m_hNetlibUser); - if (response == NULL) + if (response != NULL) { - errors++; - delete request; - continue; - } - - if (response->resultCode != 200) - { - SendRequest(new HealthTrouterRequest(ccid), &CSkypeProto::OnHealth); - break; - } - - if (response->pData) - { - char *json = strstr(response->pData, "{"); - - if (json == NULL) continue; + if (response->resultCode == 200) + { + if (response->pData) + { + char *json = strstr(response->pData, "{"); + + if (json == NULL) + continue; + + JSONROOT root(json); + ptrA szBody(mir_t2a(ptrT(json_as_string(json_get(root, "body"))))); + JSONNODE *headers = json_get(root, "headers"); + JSONNODE *body = json_parse(szBody); + OnTrouterEvent(body, headers); + } + } + else + { + SendRequest(new HealthTrouterRequest(ccid), &CSkypeProto::OnHealth); + } - JSONROOT root(json); - ptrA szBody(mir_t2a(ptrT(json_as_string(json_get(root, "body"))))); - JSONNODE *headers = json_get(root, "headers"); - JSONNODE *body = json_parse(szBody); - OnTrouterEvent(body, headers); + m_TrouterConnection = response->nlc; + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response); } - - m_TrouterConnection = response->nlc; - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response); delete request; } m_hTrouterThread = NULL; -- cgit v1.2.3