summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_trouter.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-08-23 12:41:40 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-08-23 12:41:40 +0000
commitb2c2e5c5b1eefa07a3aff95930cae6c9d1b6bc52 (patch)
tree9b3ac6ee7ad51abfb4f5e34328745c3295736e7f /protocols/SkypeWeb/src/skype_trouter.cpp
parent2036ef157e7743223a4f52f791cc821d2d45695d (diff)
SkypeWeb: more login fixes.
git-svn-id: http://svn.miranda-ng.org/main/trunk@15017 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_trouter.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp61
1 files changed, 32 insertions, 29 deletions
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp
index e3ee811fa3..1525b6b19a 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -103,10 +103,9 @@ void CSkypeProto::OnGetTrouter(const NETLIBHTTPREQUEST *response)
int iStart = 0;
CMStringA szToken = data.Tokenize(":", iStart).Trim();
TRouter.sessId = szToken.GetString();
- if (!m_hTrouterThread)
- m_hTrouterThread = ForkThreadEx(&CSkypeProto::TRouterThread, 0, NULL);
- else
- SetEvent(m_hTrouterEvent);
+
+ SetEvent(m_hTrouterEvent);
+ SetEvent(m_hTrouterHealthEvent);
if ((time(NULL) - TRouter.lastRegistrationTime) >= 3600)
{
@@ -134,41 +133,45 @@ void CSkypeProto::TRouterThread(void*)
int errors = 0;
- while (!isTerminated && errors < POLLING_ERRORS_LIMIT)
+ while (!m_bThreadsTerminated)
{
- TrouterPollRequest *request = new TrouterPollRequest(TRouter.socketIo, TRouter.connId, TRouter.st, TRouter.se, TRouter.sig, TRouter.instance, TRouter.ccid, TRouter.sessId);
- request->nlc = m_TrouterConnection;
- NLHR_PTR response(request->Send(m_hNetlibUser));
- if (response == NULL)
+ WaitForSingleObject(m_hTrouterEvent, INFINITE);
+
+ while (errors < POLLING_ERRORS_LIMIT && m_iStatus > ID_STATUS_OFFLINE)
{
- errors++;
+ TrouterPollRequest *request = new TrouterPollRequest(TRouter.socketIo, TRouter.connId, TRouter.st, TRouter.se, TRouter.sig, TRouter.instance, TRouter.ccid, TRouter.sessId);
+ request->nlc = m_TrouterConnection;
+ NLHR_PTR response(request->Send(m_hNetlibUser));
delete request;
- continue;
- }
+ if (response == NULL)
+ {
+ errors++;
+ continue;
+ }
- if (response->resultCode == 200)
- {
- if (response->pData)
+ if (response->resultCode == 200)
{
- char *json = strstr(response->pData, "{");
- if (json != NULL)
+ if (response->pData)
{
- JSONNode root = JSONNode::parse(json);
- std::string szBody = root["body"].as_string();
- const JSONNode &headers = root["headers"];
- const JSONNode body = JSONNode::parse(szBody.c_str());
- OnTrouterEvent(body, headers);
+ char *json = strstr(response->pData, "{");
+ if (json != NULL)
+ {
+ JSONNode root = JSONNode::parse(json);
+ std::string szBody = root["body"].as_string();
+ const JSONNode &headers = root["headers"];
+ const JSONNode body = JSONNode::parse(szBody.c_str());
+ OnTrouterEvent(body, headers);
+ }
}
}
+ else
+ {
+ SendRequest(new HealthTrouterRequest(TRouter.ccid.c_str()), &CSkypeProto::OnHealth);
+ WaitForSingleObject(m_hTrouterHealthEvent, INFINITE);
+ }
+ m_TrouterConnection = response->nlc;
}
- else
- {
- SendRequest(new HealthTrouterRequest(TRouter.ccid.c_str()), &CSkypeProto::OnHealth);
- WaitForSingleObject(m_hTrouterEvent, INFINITE);
- }
- m_TrouterConnection = response->nlc;
- delete request;
}
m_hTrouterThread = NULL;
m_TrouterConnection = NULL;