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


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

本文整理汇总了C++中CCHttpResponse::getHttpRequest方法的典型用法代码示例。如果您正苦于以下问题:C++ CCHttpResponse::getHttpRequest方法的具体用法?C++ CCHttpResponse::getHttpRequest怎么用?C++ CCHttpResponse::getHttpRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCHttpResponse的用法示例。


在下文中一共展示了CCHttpResponse::getHttpRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onHttpRequestCompleted

void GameState::onHttpRequestCompleted(CCNode* sender,void *data)
{
	CCHttpResponse *response = (CCHttpResponse*)data;
	if(!response)
		return;

	if( NULL != strlen(response->getHttpRequest()->getTag()))
	{
		CCLog("%s complete.",response->getHttpRequest()->getTag());
	}
	int statusCode = response->getResponseCode();
	CCLog("response code : %d",statusCode);

	if(!response->isSucceed())
	{
		CCLog("response failed");
		CCLog("errorbuffer: %s",response->getErrorBuffer());
		return;
	}
	std::vector<char>* buffer = response->getResponseData();

	char str[200] = {""};
	unsigned int i;

	for(i=0;i<buffer->size();i++)
	{
		str[i] = (*buffer)[i];
	}
	str[i] = '\0';
	CCLog("%s",str);
}
开发者ID:CicadaKim,项目名称:ZombieHunter,代码行数:31,代码来源:GameState.cpp

示例2: downloadFileFinished

void ParseFile::downloadFileFinished(CCNode* sender, void* param)
{
	CCString* savePathName = 0;
	ParseError* error = new ParseError();

	CCHttpResponse* response = (CCHttpResponse*)param;
	
	if (response->getResponseCode() == 200)
	{
		FILE* file = 0;
		const char* errorMsg = 0;
		savePathName = (CCString*)response->getHttpRequest()->getUserData();
		std::vector<char>* responseData = response->getResponseData();
		do
		{
			file = fopen(savePathName->getCString(), "wb");
			if (file == 0)
			{
				errorMsg = "error open file!";
				break;
			}
			size_t writeLen = fwrite(&responseData->front(), 1, responseData->size(), file);
			if (writeLen != responseData->size())
			{
				errorMsg = "error write file!";
				break;
			}
		}while(0);

		if (file)
		{
			fclose(file);
		}
		if (errorMsg)
		{
			error->SetError(errorMsg);
		}
	}
	else
	{
		if (strlen(response->getErrorBuffer()) > 0)
		{
			error->SetError(response->getErrorBuffer());
		}
		else
		{
			std::vector<char>* responseData = response->getResponseData();
			responseData->push_back('\0');
			error->SetError(&responseData->front());
		}
	}

	this->downloadFileCompleted(savePathName?savePathName->getCString():0, error);

	savePathName = (CCString*)response->getHttpRequest()->getUserData();
	savePathName->release();

	delete error;
}
开发者ID:Whislly,项目名称:DreamBookToolbox,代码行数:59,代码来源:ParseFile.cpp

示例3: onHttpRequestCompleted

void EziSocialObject::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
{
    
    CCHttpResponse* response = (CCHttpResponse*)data;
    
    if (!response)
    {
        CCLOG("[EziSocial Error]: No Response");
    }
    
    if (0 != strlen(response->getHttpRequest()->getTag()))
    {
        //CCLog("%s completed", response->getHttpRequest()->getTag());
    }
    
    int statusCode = response->getResponseCode();
    
    char statusString[64] = {};
    sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
    
    if (!response->isSucceed())
    {
        CCLog("[EziSocial Error]: response failed");
        CCLog("[EziSocial Error]: error buffer: %s", response->getErrorBuffer());
        return;
    }
    
    // Dump the data
    std::vector<char> *buffer = response->getResponseData();
    
    // Create the CCSprite from data dump...
    
    CCImage * img=new CCImage();
    img->initWithImageData(&(buffer->front()), buffer->size());
    
    // Save file for resue.
    std::string writablePath = CCFileUtils::sharedFileUtils()->getWritablePath();
    writablePath.append(response->getHttpRequest()->getTag());
    img->saveToFile(writablePath.c_str());
    delete img;
    
    const char* userID = "";
    std::string tagString = "";
    tagString.append(response->getHttpRequest()->getTag());
    
    std::vector< std::string > strings = EziSocialObject::tokenizeStr(tagString, "_");
    userID = strings[0].c_str();
    
    internalUserPhotoCallback(writablePath.c_str(), userID);
}
开发者ID:KevinLion,项目名称:EziSocial-Plugin,代码行数:50,代码来源:EziSocialObject.cpp

示例4:

void S411FeedBack::onPostFinished(CCNode *node,void *data)
{
    AppDelegate::loadingLabel ->setString("");
    _menu->setEnabled(true);
	CCHttpResponse *response = (CCHttpResponse*)data;
	if (!response)
	{
		return;
	}
	int s=response->getHttpRequest()->getRequestType();
	CCLOG("request type %d",s);
    
    
	if (0 != strlen(response->getHttpRequest()->getTag()))
	{
		CCLOG("%s ------>oked", response->getHttpRequest()->getTag());
	}
    
	int statusCode = response->getResponseCode();
	CCLOG("response code: %d", statusCode);
    
    
	char statusString[64] = {};
	sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
	CCLOG("statusString");
    
	if (!response->isSucceed())
	{
		CCLOG("response failed");
		CCLOG("error buffer: %s", response->getErrorBuffer());
        AppDelegate::loadingLabel->setString("提交失败");
        this->schedule(schedule_selector(S411FeedBack::time),1.0f,false,0.0);
		return;
	}
    
    
    
    
	//上面这些都是一些判断是否请求成功,下面这个是获得的请求数据
	std::vector<char> *buffer = response->getResponseData();
	CCLOG("Http Test, dump data: ");
	for (unsigned int i = 0; i < buffer->size(); i++)
	{
		CCLOG("%c", (*buffer)[i]);//这里打印从服务器返回的数据
        
	}
	CCLOG("\n");
    AppDelegate::loadingLabel->setString("提交成功");
    this->schedule(schedule_selector(S411FeedBack::time),1.0f,false,0.0);
}
开发者ID:Ratel13,项目名称:JinRiCompany,代码行数:50,代码来源:S411FeedBack.cpp

示例5: onHttpRequestCompleted

void InGameScene::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
{
    CCHttpResponse *response = (CCHttpResponse*)data;
    
    if (!response)
    {
        return;
    }
    
    // You can get original request type from: response->request->reqType
    if (0 != strlen(response->getHttpRequest()->getTag()))
    {
        CCLog("%s completed", response->getHttpRequest()->getTag());
    }
    
    int statusCode = response->getResponseCode();
    char statusString[64] = {};
    sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
    //m_labelStatusCode->setString(statusString);
    CCLog("response code: %d", statusCode);
    
    if (!response->isSucceed())
    {
        CCLog("response failed");
        CCLog("error buffer: %s", response->getErrorBuffer());
        return;
    }
    
    // dump data
    std::vector<char> *buffer = response->getResponseData();
	std::string s = "";
    bool isDataStarted = false;
    for (unsigned int i = 0; i < buffer->size(); i++)
	{
        if( isDataStarted == false && !isspace((*buffer)[i]) )
            isDataStarted = true;
        if( isDataStarted == false) continue;
        
		s += (*buffer)[i];
    }
	CCLog("%s", s.data() );
    CCLog("\n");
    
    if( strcmp(response->getHttpRequest()->getTag(), "URL_CREATE_ANIMAL") == 0)
    {
        string szAnimalKey = s;
        CCLog("InGameScene::onHttpRequestCompleted-%s : %s", response->getHttpRequest()->getTag(), szAnimalKey.data() );
    }
}
开发者ID:JungHanter,项目名称:SWMTAMA,代码行数:49,代码来源:InGameScene.cpp

示例6: requestFinishedCallback

void ChatLayer::requestFinishedCallback(CCNode* pSender,void *data)
{
    CCHttpResponse *response =  (CCHttpResponse*)data;
	if(response==NULL)
	{
		return;
	}
	int statusCode = response->getResponseCode();
	char statusString[64] = {};
	CCLOG(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());

	if (!response->isSucceed())   
	{  
		CCLog("response failed");  
		CCLog("error buffer: %s", response->getErrorBuffer());  
		return;  
	}
	std::vector<char> *buffer = response->getResponseData(); 

	std::string content(buffer->begin(),buffer->end());

	XMLParser *xmlParser = XMLParser::parseWithString(content.c_str());
	CCLOG("%s",xmlParser->getString("content")->getCString());

//	parseJson();
}
开发者ID:crazyit,项目名称:iGame,代码行数:26,代码来源:ChatLayer.cpp

示例7: dispatchResponseCallbacks

// Poll and notify main thread if responses exists in queue
KDvoid CCHttpClient::dispatchResponseCallbacks ( KDfloat fDelta )
{ 
    CCHttpResponse*  pResponse = KD_NULL;
    
	kdThreadMutexLock ( l_pResponseQueueMutex );
    if ( l_pResponseQueue->count ( ) )
    {
        pResponse = dynamic_cast<CCHttpResponse*> ( l_pResponseQueue->objectAtIndex ( 0 ) );
        l_pResponseQueue->removeObjectAtIndex ( 0 );
    }
    kdThreadMutexUnlock ( l_pResponseQueueMutex );
    
    if ( pResponse )
    {
        --l_uAsyncRequestCount;
        
        CCHttpRequest*  pRequest = pResponse->getHttpRequest ( );
        CCObject*        pTarget = pRequest->getTarget ( );
        SEL_CallFuncND pSelector = pRequest->getSelector ( );

        if ( pTarget && pSelector ) 
        {
            ( pTarget->*pSelector ) ( (CCNode*) this, pResponse );
        }
        
        pResponse->release ( );
    }
    
    if ( 0 == l_uAsyncRequestCount ) 
    {
        CCDirector::sharedDirector ( )->getScheduler ( )->pauseTarget ( this );
    }   
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:34,代码来源:HttpClient.cpp

示例8: onHttpRequestCompleted

void MyHttpRequest::onHttpRequestCompleted(CCNode *sender,void *data)  
{  
	m_isCompleted=true;
	CCHttpResponse *response = (CCHttpResponse*)data;  
	if (!response)  
	{  
		return;  
	}  
	int s=response->getHttpRequest()->getRequestType();  
	CCLog("request type %d",s);  


	if (0 != strlen(response->getHttpRequest()->getTag()))   
	{  
		CCLog("%s ------>oked", response->getHttpRequest()->getTag());  
	}  

	int statusCode = response->getResponseCode();  
	CCLog("response code: %d", statusCode);  


	char statusString[64] = {};  
	sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());  
	CCLog(statusString);  

	if (!response->isSucceed())   
	{  
		CCLog("response failed");  
		CCLog("error buffer: %s", response->getErrorBuffer());  
		return;  
	}  

	std::vector<char> *buffer = response->getResponseData(); 
	printf("Http Test, dump data: ");  
	for (unsigned int i = 0; i < buffer->size(); i++)  
	{  
		//CCLog("%c", (*buffer)[i]);//这里打印从服务器返回的数据  
		m_responseData.push_back((*buffer)[i]);
	}  
	CCLog("m_responseData:%s",m_responseData.c_str());
	printf("\n");  

} 
开发者ID:pzhifeng,项目名称:client-main,代码行数:43,代码来源:MyHttpRequest.cpp

示例9: onHttpRequestCompleted

void RequestTopaz::onHttpRequestCompleted(CCNode *sender, void *data)
{
    // Loading 창 끄기
    ((Loading*)Depth::GetCurPointer())->EndScene();
    
    CCHttpResponse* res = (CCHttpResponse*) data;
    
    xml_document xmlDoc;
    Network::GetXMLFromResponseData(res, xmlDoc);
    
    std::string friendKakaoId = res->getHttpRequest()->getTag();
    XmlParseResult(&xmlDoc, friendKakaoId);
}
开发者ID:playdandi,项目名称:CocoDrawingMagic,代码行数:13,代码来源:RequestTopaz.cpp

示例10: onHttpRequestCompleted

void HttpClientTest::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
{
    CCHttpResponse *response = (CCHttpResponse*)data;

    if (!response)
    {
        return;
    }
    
    // You can get original request type from: response->request->reqType
    if (0 != strlen(response->getHttpRequest()->getTag())) 
    {
        CCLog("%s completed", response->getHttpRequest()->getTag());
    }
    
    int statusCode = response->getResponseCode();
    char statusString[64] = {};
    sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
    m_labelStatusCode->setString(statusString);
    CCLog("response code: %d", statusCode);
    
    if (!response->isSucceed()) 
    {
        CCLog("response failed");
        CCLog("error buffer: %s", response->getErrorBuffer());
        return;
    }
    
    // dump data
    std::vector<char> *buffer = response->getResponseData();
    printf("Http Test, dump data: ");
    for (unsigned int i = 0; i < buffer->size(); i++)
    {
        printf("%c", (*buffer)[i]);
    }
    printf("\n");
}
开发者ID:acc85,项目名称:cocos2d-x,代码行数:37,代码来源:HttpClientTest.cpp

示例11: dispatchResponseCallbacks

// Poll and notify main thread if responses exists in queue
void CCHttpClient::dispatchResponseCallbacks(float delta)
{
    // CCLog("CCHttpClient::dispatchResponseCallbacks is running");
    
    CCHttpResponse* response = NULL;
    
    pthread_mutex_lock(&s_responseQueueMutex);
    if (s_responseQueue->count())
    {
        response = dynamic_cast<CCHttpResponse*>(s_responseQueue->objectAtIndex(0));
        s_responseQueue->removeObjectAtIndex(0);
    }
    pthread_mutex_unlock(&s_responseQueueMutex);
    
    if (response)
    {
        --s_asyncRequestCount;
        
        CCHttpRequest *request = response->getHttpRequest();
        CCObject *pTarget = request->getTarget();
        SEL_CallFuncND pSelector = request->getSelector();

        if (pTarget && pSelector) 
        {
            (pTarget->*pSelector)((CCNode *)this, response);
        }

		if (!request->_jsTarget.IsEmpty() && !request->_jsSelector.IsEmpty()) {

			response->flushDataToReadBuffer();
            response->assignJavaScriptObject(CLS_CCHTTPRESPONSE_ID, false);
			this->getJSCCallFunc()->callJSFunction(request->_jsTarget, request->_jsSelector, this->getJSObjInstance(), response->getJSObjInstance());
		}
        
        response->release();
    }
    
    if (0 == s_asyncRequestCount) 
    {
        CCDirector::sharedDirector()->getScheduler()->pauseTarget(this);
    }
    
}
开发者ID:TukekeSoft,项目名称:jacos2d-x,代码行数:44,代码来源:HttpClient.cpp

示例12: dispatchResponseCallbacks

// Poll and notify main thread if responses exists in queue
void CCHttpClient::dispatchResponseCallbacks(float delta)
{
    // CCLog("CCHttpClient::dispatchResponseCallbacks is running");
    
    CCHttpResponse* response = NULL;
    
    pthread_mutex_lock(&s_responseQueueMutex);
    if (s_responseQueue->count())
    {
        response = dynamic_cast<CCHttpResponse*>(s_responseQueue->objectAtIndex(0));
        s_responseQueue->removeObjectAtIndex(0);
    }
    pthread_mutex_unlock(&s_responseQueueMutex);
    
    if (response)
    {
        --s_asyncRequestCount;
        
        CCHttpRequest *request = response->getHttpRequest();
        CCObject *pTarget = request->getTarget();
        SEL_CallFuncND pSelector = request->getSelector();

        if (pTarget && pSelector) 
        {
            (pTarget->*pSelector)((CCNode *)this, response);
        }

        //lua
        if( request->getLuaCallback() != 0 )
        {
            ptola::script::CLuaScriptFunctionInvoker::executeHttpResponseCallback(request->getLuaCallback(), response);
        }
        
        response->release();
    }
    
    if (0 == s_asyncRequestCount) 
    {
        CCDirector::sharedDirector()->getScheduler()->pauseTarget(this);
    }
    
}
开发者ID:jindaw,项目名称:game_sources,代码行数:43,代码来源:HttpClient.cpp

示例13: onHttpRequestCompletedNoEncrypt

void RequestTopaz::onHttpRequestCompletedNoEncrypt(CCNode *sender, void *data)
{
    CCHttpResponse* res = (CCHttpResponse*) data;
    char dumpData[110*110*2];
    
    // 프로필 사진 받아오기 실패
    if (!res || !res->isSucceed())
    {
        //CCLog("res failed. error buffer: %s", res->getErrorBuffer());
        return;
    }
    
    // dump data
    std::vector<char> *buffer = res->getResponseData();
    for (unsigned int i = 0 ; i < buffer->size() ; i++)
        dumpData[i] = (*buffer)[i];
    dumpData[buffer->size()] = NULL;
    
    // make texture2D
    CCImage* img = new CCImage;
    img->initWithImageData(dumpData, (int)buffer->size());
    CCTexture2D* texture = new CCTexture2D();
    texture->initWithImage(img);
    
    // set CCSprite (profile 모음 리스트에 갱신)
    int numOfList = friendList.size();
    int index = atoi(res->getHttpRequest()->getTag());
    
    ProfileSprite* psp = ProfileSprite::GetObj(friendList[index]->GetImageUrl());
    psp->SetSprite(texture);
    psp->SetLoadingDone(true);
    
    // 화면에 보이는 스프라이트 교체
    if (spriteClassScroll == NULL)
        return;
    spriteClassScroll->ChangeSprite(-888*(numOfList-index), psp->GetProfile());
    ((CCSprite*)spriteClassScroll->FindSpriteByTag(-777*(numOfList-index)))->setOpacity(255);
}
开发者ID:playdandi,项目名称:CocoDrawingMagic,代码行数:38,代码来源:RequestTopaz.cpp

示例14: dispatchResponseCallbacks

// Poll and notify main thread if responses exists in queue
void CCHttpClient::dispatchResponseCallbacks(float delta)
{
    // CCLog("CCHttpClient::dispatchResponseCallbacks is running");
    
    CCHttpResponse* response = NULL;
    
    pthread_mutex_lock(&s_responseQueueMutex);
    if (s_responseQueue->count())
    {
        response = dynamic_cast<CCHttpResponse*>(s_responseQueue->objectAtIndex(0));
        s_responseQueue->removeObjectAtIndex(0);
    }
    pthread_mutex_unlock(&s_responseQueueMutex);
    
    if (response)
    {
        --s_asyncRequestCount;
        
        CCHttpRequest *request = response->getHttpRequest();
        CAObject *pTarget = request->getTarget();
        SEL_HttpResponse pSelector = request->getSelector();

        if (pTarget && pSelector) 
        {
            (pTarget->*pSelector)(this, response);
        }
        
        response->release();
    }
    
    if (0 == s_asyncRequestCount) 
    {
        CAScheduler::getScheduler()->pauseTarget(this);
    }
    
}
开发者ID:AojiaoZero,项目名称:CrossApp,代码行数:37,代码来源:HttpClient.cpp

示例15: requestFinishedCallback

void MailMainScene::requestFinishedCallback(CCNode* pSender,void *Rspdata)
{
	if (!this->ValidateResponseData(pSender,Rspdata))
	{
		return;
	}

	CCHttpResponse *response =  (CCHttpResponse*)Rspdata;
	std::vector<char> *buffer = response->getResponseData();

	std::string content(buffer->begin(),buffer->end());
	CCLog(content.c_str());

    CCDictionary * dictionary = CCJSONConverter::sharedConverter()->dictionaryFrom(content.c_str());
	int code = ((CCNumber *)dictionary->objectForKey("code"))->getIntValue();
    if (code != 200) {
        CCMessageBox("invoke web api failed!","ERROR");
        return;
    }

	std::string requestTag(response->getHttpRequest()->getTag());

	if (requestTag == "101") {
		mFriendList = dynamic_cast<CCArray *>(dictionary->objectForKey("friendList"));
		if (mFriendList==NULL)
		{
			return;
		}

		selectedindex = -1;
		mTableViewFriend->reloadData();
	} else if (requestTag == "102"){
		this->doSearchFriend();
		CCMessageBox("delete friend successfully","Success");
	}
}
开发者ID:webhunter,项目名称:iGame,代码行数:36,代码来源:MailMainScene.cpp


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