summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_trouter.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-05-02 14:34:42 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-05-02 14:34:42 +0000
commitcf379ef3c47b386c970d7d0f8724f85abcbff8cc (patch)
tree2d4ee097db62491c252e987bfc3a74835f52389b /protocols/SkypeWeb/src/skype_trouter.cpp
parent438d7d37135645c4c57c87b9375a4c96e2359d46 (diff)
SkypeWeb: Polling refactoring. Small fix.
git-svn-id: http://svn.miranda-ng.org/main/trunk@13374 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_trouter.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp50
1 files changed, 24 insertions, 26 deletions
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;