当前位置: 首页>>代码示例>>C++>>正文


C++ HttpResponse::getHttpRequest方法代码示例

本文整理汇总了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()
    }
开发者ID:CryQ,项目名称:coclua,代码行数:28,代码来源:RequestManager.cpp

示例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();
    }
}
开发者ID:6520874,项目名称:pipiGame,代码行数:31,代码来源:HttpClient.cpp

示例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();
    }
}
开发者ID:hugohuang1111,项目名称:Bird,代码行数:36,代码来源:HttpClient.cpp

示例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();
    }
}
开发者ID:253627764,项目名称:WagonWar,代码行数:34,代码来源:HttpClient.cpp

示例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);
    }
    
}
开发者ID:Ben-Cortina,项目名称:GameBox,代码行数:39,代码来源:HttpClient.cpp


注:本文中的HttpResponse::getHttpRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。