Adds network ifiles to xcode project again.

This commit is contained in:
James Chen
2018-03-06 10:40:24 +08:00
parent faa3401f93
commit 2bd4b4c3c4
5 changed files with 60 additions and 64 deletions
+22 -22
View File
@@ -29,7 +29,7 @@
#include <queue>
#include <errno.h>
#include <curl/curl.h>
#include "base/CCDirector.h"
//#include "base/CCDirector.h"
#include "platform/CCFileUtils.h"
NS_CC_BEGIN
@@ -115,10 +115,10 @@ void HttpClient::networkThread()
_responseQueueMutex.unlock();
_schedulerMutex.lock();
if (nullptr != _scheduler)
{
_scheduler->performFunctionInCocosThread(CC_CALLBACK_0(HttpClient::dispatchResponseCallbacks, this));
}
// if (nullptr != _scheduler)
// {
// _scheduler->performFunctionInCocosThread(CC_CALLBACK_0(HttpClient::dispatchResponseCallbacks, this));
// }
_schedulerMutex.unlock();
}
@@ -143,20 +143,20 @@ void HttpClient::networkThreadAlone(HttpRequest* request, HttpResponse* response
processResponse(response, responseMessage);
_schedulerMutex.lock();
if (nullptr != _scheduler)
{
_scheduler->performFunctionInCocosThread([this, response, request]{
const ccHttpRequestCallback& callback = request->getResponseCallback();
if (callback != nullptr)
{
callback(this, response);
}
response->release();
// do not release in other thread
request->release();
});
}
// if (nullptr != _scheduler)
// {
// _scheduler->performFunctionInCocosThread([this, response, request]{
// const ccHttpRequestCallback& callback = request->getResponseCallback();
//
// if (callback != nullptr)
// {
// callback(this, response);
// }
// response->release();
// // do not release in other thread
// request->release();
// });
// }
_schedulerMutex.unlock();
decreaseThreadCountAndMayDeleteThis();
@@ -356,9 +356,9 @@ void HttpClient::destroyInstance()
auto thiz = _httpClient;
_httpClient = nullptr;
thiz->_scheduler->unscheduleAllForTarget(thiz);
// thiz->_scheduler->unscheduleAllForTarget(thiz);
thiz->_schedulerMutex.lock();
thiz->_scheduler = nullptr;
// thiz->_scheduler = nullptr;
thiz->_schedulerMutex.unlock();
thiz->_requestQueueMutex.lock();
@@ -400,7 +400,7 @@ HttpClient::HttpClient()
{
CCLOG("In the constructor of HttpClient!");
memset(_responseMessage, 0, RESPONSE_BUFFER_SIZE * sizeof(char));
_scheduler = Director::getInstance()->getScheduler();
// _scheduler = Director::getInstance()->getScheduler();
increaseThreadCount();
}