本文整理汇总了C++中HttpResponse::getHttpRequest方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpResponse::getHttpRequest方法的具体用法?C++ HttpResponse::getHttpRequest怎么用?C++ HttpResponse::getHttpRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpResponse
的用法示例。
在下文中一共展示了HttpResponse::getHttpRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: httpRequestDidCompleted
void RequestManager::httpRequestDidCompleted(Object *sender, network::HttpResponse *data){
HttpResponse *response = data;
HttpRequest *request = response->getHttpRequest();
BLOCK()
const char *type = request->getTag();
if (!response || !strlen(type)){
LEAVE()
}
log(1,"%s completed", type);
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code=>%d, tag = %s", statusCode, request->getTag());
log(1,"response code==>%d", statusCode);
if (!response->isSucceed()){
log(1,"response failed");
log(1,"error buffer: %s", response->getErrorBuffer());
std::string temName = response->getErrorBuffer();
if (temName.length() > 0){
if (!((unsigned)temName[0]&0x80)){
//you need to translate ascii to chinese
}
}
this->dispatchRequestDidFail(type, temName.c_str());
LEAVE()
}
示例2: dispatchResponseCallbacks
// Poll and notify main thread if responses exists in queue
void HttpClient::dispatchResponseCallbacks()
{
// log("CCHttpClient::dispatchResponseCallbacks is running");
HttpResponse* response = nullptr;
s_responseQueueMutex.lock();
if (!s_responseQueue->empty())
{
response = s_responseQueue->at(0);
s_responseQueue->erase(0);
}
s_responseQueueMutex.unlock();
if (response)
{
HttpRequest *request = response->getHttpRequest();
Object *pTarget = request->getTarget();
SEL_HttpResponse pSelector = request->getSelector();
if (pTarget && pSelector)
{
(pTarget->*pSelector)(this, response);
}
response->release();
}
}
示例3: dispatchResponseCallbacks
// Poll and notify main thread if responses exists in queue
void HttpClient::dispatchResponseCallbacks()
{
// log("CCHttpClient::dispatchResponseCallbacks is running");
//occurs when cocos thread fires but the network thread has already quited
HttpResponse* response = nullptr;
_responseQueueMutex.lock();
if (!_responseQueue.empty())
{
response = _responseQueue.at(0);
_responseQueue.erase(0);
}
_responseQueueMutex.unlock();
if (response)
{
HttpRequest *request = response->getHttpRequest();
const ccHttpRequestCallback& callback = request->getCallback();
Ref* pTarget = request->getTarget();
SEL_HttpResponse pSelector = request->getSelector();
if (callback != nullptr)
{
callback(this, response);
}
else if (pTarget && pSelector)
{
(pTarget->*pSelector)(this, response);
}
response->release();
// do not release in other thread
request->release();
}
}
示例4: dispatchResponseCallbacks
// Poll and notify main thread if responses exists in queue
void HttpClient::dispatchResponseCallbacks()
{
// log("CCHttpClient::dispatchResponseCallbacks is running");
//occurs when cocos thread fires but the network thread has already quited
if (nullptr == s_responseQueue) {
return;
}
HttpResponse* response = nullptr;
s_responseQueueMutex.lock();
if (!s_responseQueue->empty())
{
response = s_responseQueue->at(0);
s_responseQueue->erase(0);
}
s_responseQueueMutex.unlock();
if (response)
{
HttpRequest *request = response->getHttpRequest();
Ref* pTarget = request->getTarget();
SEL_HttpResponse pSelector = request->getSelector();
if (pTarget && pSelector)
{
(pTarget->*pSelector)(this, response);
}
response->release();
}
}
示例5: dispatchResponseCallbacks
// Poll and notify main thread if responses exists in queue
void HttpClient::dispatchResponseCallbacks(float delta)
{
// log("CCHttpClient::dispatchResponseCallbacks is running");
HttpResponse* response = NULL;
s_responseQueueMutex.lock();
if (s_responseQueue->count())
{
response = dynamic_cast<HttpResponse*>(s_responseQueue->objectAtIndex(0));
s_responseQueue->removeObjectAtIndex(0);
}
s_responseQueueMutex.unlock();
if (response)
{
--s_asyncRequestCount;
HttpRequest *request = response->getHttpRequest();
Object *pTarget = request->getTarget();
SEL_HttpResponse pSelector = request->getSelector();
if (pTarget && pSelector)
{
(pTarget->*pSelector)(this, response);
}
response->release();
}
if (0 == s_asyncRequestCount)
{
Director::getInstance()->getScheduler()->pauseTarget(this);
}
}