summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_trouter.cpp
diff options
context:
space:
mode:
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;