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


C++ CCHttpRequest类代码示例

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


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

示例1: kdThreadMutexLock

// 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

示例2: closeLogInTable

void LogInScene::LogInHTTP(){
    
    closeLogInTable();
    
    if (UserNameStr != "" && PassWordStr !="" && ((UserNameStr != MainUser->UserNameStr && MainUser->hasLogIn) || !MainUser->hasLogIn)) {
        
        box = AsMessageBox::createMessageBox("通信中,请稍候", 1, 0);
        box->setPosition(CCPointZero);
        addChild(box,100);
        
        CCHttpRequest* request = new CCHttpRequest();
        string UrlData = "http://115.29.168.228/users/signin?user[name]=" + UserNameStr + "&user[password]=" + PassWordStr;
        request->setUrl(UrlData.c_str());
        request->setRequestType(CCHttpRequest::kHttpGet);
        request->setResponseCallback(this, callfuncND_selector(LogInScene::LogInRequestCompleted));
        CCHttpClient::getInstance()->send(request);
        request->release();
    }
    else if(UserNameStr == ""){
        box = AsMessageBox::createMessageBox("请输入用户名", 2, 1);
        box->setPosition(CCPointZero);
        addChild(box,100);
    }
    else if(UserNameStr == MainUser->UserNameStr){
        box = AsMessageBox::createMessageBox("该账户已经登录", 2, 1);
        box->setPosition(CCPointZero);
        addChild(box,100);
    }
    else if(PassWordStr == ""){
        box = AsMessageBox::createMessageBox("请输入密码", 2, 1);
        box->setPosition(CCPointZero);
        addChild(box,100);
    }
}
开发者ID:nooboracle,项目名称:ForTest,代码行数:34,代码来源:LogInHTTP.cpp

示例3: httpRequestLua

CCHttpRequest* CCNetwork::httpRequestLua(LUA_FUNCTION listener,
                                         const char* url,
                                         CCHttpRequestMethod method)
{
    CCHttpRequest* request = CCHttpRequest::createWithUrlLua(listener, url, method);
    request->start();
    return request;
}
开发者ID:AungPyae,项目名称:cocos2d-x-extensions,代码行数:8,代码来源:CCNetwork_common.cpp

示例4: CCHttpRequest

CCHttpRequest* CHttpServer::getGetRequestByUrl(const char* pUrl)
{
	CCHttpRequest* pRequest = new CCHttpRequest();
	pRequest->setUrl(pUrl);
	pRequest->setRequestType(CCHttpRequest::kHttpGet);
	addDefaultHeaders(pRequest);
	return pRequest;
}
开发者ID:jabelai,项目名称:Neverland,代码行数:8,代码来源:httpserver.cpp

示例5: open

	void open(CCHttpRequest::HttpRequestType type, const char* url){

		CC_SAFE_RELEASE_NULL(m_request);
		m_request = new CCHttpRequest(); 

		m_request->setUrl(url); 
		m_request->setRequestType(type); 
		m_request->setResponseCallback(this, callfuncND_selector(HttpRequest::responseCallback));
	};
开发者ID:akira-cn,项目名称:cocos2dx-cqwrap,代码行数:9,代码来源:cqwrap_httprequest_manual.cpp

示例6: CCHttpRequest

void ASUser::getHeroInformationHTTP(){
    CCHttpRequest* request = new CCHttpRequest();
    string UrlData = "http://115.29.168.228/roles?token=" + UserTokenStr;
    request->setUrl(UrlData.c_str());
    request->setRequestType(CCHttpRequest::kHttpGet);
    request->setResponseCallback(this, callfuncND_selector(ASUser::getHeroInformationRequestCompleted));
    CCHttpClient::getInstance()->send(request);
    request->release();
}
开发者ID:nooboracle,项目名称:ForTest,代码行数:9,代码来源:AsHeroInfoHTTP.cpp

示例7: CCHttpRequest

CCHttpRequest* CCHttpRequest::createWithUrlLua(int nHandler, const char* url, bool isGet)
{
    CCHttpRequest* request = new CCHttpRequest(NULL, url, isGet?CCHttpRequestMethodGET:CCHttpRequestMethodPOST, true);
    request->m_luaHandler = nHandler;
    request->initHttpRequest();
    request->autorelease();
    request->retain();
    return request;
}
开发者ID:liyonghelpme,项目名称:cocos2dNet,代码行数:9,代码来源:CCHttpRequest.cpp

示例8: testUrl

void CLoginScene::testUrl()
{
	CSceneManager::sharedSceneManager()->openPopupBox(GETBOX(CLoadingBox), (void*)(""));
	OppoServer* pServer = OppoServer::shareOppoServer();
	CCHttpRequest* request = CHttpServer::getGetRequestByUrl("http://www.bsdfsaidu.com");
	request->setResponseCallback(this, callfuncND_selector(CLoginScene::urlCallback));
	pServer->send(request);
	request->release();
}
开发者ID:jabelai,项目名称:Neverland,代码行数:9,代码来源:LoginScene.cpp

示例9: CCLog

void OnlineController::_discoverServer(float)
{
    CCLog("== discovering server");
    CCHttpRequest* request = new CCHttpRequest;
    request->setUrl("https://dl.dropboxusercontent.com/u/19446960/discover/discover.html");
    request->setRequestData("", 1);
    request->setRequestType(CCHttpRequest::kHttpGet);
    request->setResponseCallback(this, httpresponse_selector(OnlineController::_onServerDiscovered));
    CCHttpClient::getInstance()->send(request);
}
开发者ID:timur-losev,项目名称:HungryChameleon,代码行数:10,代码来源:OnlineController.cpp

示例10: CCHttpRequest

void RankScene::getServerTime(){
    
    CCHttpRequest* request = new CCHttpRequest();
    string UrlData = "http://115.29.168.228/time";
    request->setUrl(UrlData.c_str());
    request->setRequestType(CCHttpRequest::kHttpGet);
    request->setResponseCallback(this, callfuncND_selector(RankScene::getServerTimeRequestCompleted));
    CCHttpClient::getInstance()->send(request);
    request->release();
}
开发者ID:nooboracle,项目名称:ForTest,代码行数:10,代码来源:RankListHTTP.cpp

示例11: httpRequest

NS_CC_EXT_BEGIN

CCHttpRequest* CCNetwork::httpRequest(CCHttpRequestDelegate* delegate,
                                      const char* url,
                                      CCHttpRequestMethod method)
{
    CCHttpRequest* request = CCHttpRequest::createWithUrl(delegate, url, method);
    request->start();
    return request;
}
开发者ID:AungPyae,项目名称:cocos2d-x-extensions,代码行数:10,代码来源:CCNetwork_common.cpp

示例12: curl_easy_init

bool ShopItemInfoFromServer::downloadConfigFileListOneTime(const char* url,const char* postMessage)
{
	if (url == NULL) {
		return false;
	}

	std::string strHtml = "";
	std::string strRetData = "";    

	CURLcode curlRes;
	CURL* easyCurl = curl_easy_init();
	if (easyCurl == NULL) {
		return false;
	}
    ShopItemInfoFromServer::sharedInstance()->m_strFileList = "";
	//curl_easy_setopt(easyCurl, CURLOPT_WRITEFUNCTION, &ShopItemInfoFromServer::configFileDownLoadCallback);
	//curl_easy_setopt(easyCurl, CURLOPT_POSTFIELDS, postMessage);
	//curl_easy_setopt(easyCurl, CURLOPT_WRITEDATA, &strHtml);
	//curl_easy_setopt(easyCurl, CURLOPT_URL,url);
	//curl_easy_setopt(easyCurl, CURLOPT_POST, 1);
	//curl_easy_setopt(easyCurl, CURLOPT_FOLLOWLOCATION, true);
	//curlRes = curl_easy_perform(easyCurl);
	//curl_easy_cleanup(easyCurl);

	curl_easy_setopt(easyCurl,CURLOPT_URL,url);  
    // curl_easy_setopt(easyCurl, CURLOPT_CONNECTTIMEOUT,2.5);
	curl_easy_setopt(easyCurl,CURLOPT_WRITEFUNCTION,&ShopItemInfoFromServer::configFileDownLoadCallback);  
	curlRes=curl_easy_perform(easyCurl);  
	if(curlRes!=CURLE_OK)  
	{  
		char temp[100];
		snprintf(temp,100,  "failed to get product list err code %i",curlRes); 
		//AppDelegate::GetShareAppDelegate()->ShowToast(temp);
		CCLOG("%s", temp);
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
		//send failed log to c01
		{
        CCHttpRequest* request = new CCHttpRequest();
		snprintf( temp,100, "http://report.st.61.com/misc.js?gameid=82&step=3&flag=%d",curlRes); 
        request->setUrl(temp);
        request->setRequestType(CCHttpRequest::kHttpGet);
        request->setResponseCallback((CCObject*)this, callfuncND_selector(ShopItemInfoFromServer::onHttpRequestCompleted));
		
		CCHttpClient::getInstance()->send(request);
        request->release();
    	}
#endif
	}  

	curl_easy_cleanup(easyCurl);  

	bool result = (curlRes == CURLE_OK);

	return result;
}
开发者ID:JamShan,项目名称:xcode_jifengyongzhezhuan,代码行数:55,代码来源:ShopItemInfoFromServer.cpp

示例13: CCHttpRequest

void ClientConnect::RegisterRequest(const char* account, const char* pwd)
{
	CCHttpRequest* request = new CCHttpRequest();
	string path = m_ip;
	path.append("game_web/regist?account=" + string(account) + "&password=" + string(pwd));
	request->setUrl(path.c_str());
	request->setRequestType(CCHttpRequest::kHttpGet);
	request->setResponseCallback(this, callfuncND_selector(ClientConnect::onHttpRequestRegisterCallBack));
	CCHttpClient::getInstance()->send(request);
	request->release();
}
开发者ID:quinsmpang,项目名称:LDClient-src-and-scrips,代码行数:11,代码来源:ClientConnect.cpp

示例14: getCurrentTime

void CDownloadPackage::requestVersionInfo()
{
	std::string sUpdateServer = CCUserDefault::sharedUserDefault()->getStringForKey(SERVER_FOR_UPDATE);
	CCString* pUrl = CCString::createWithFormat("%s%s?r=%ld", sUpdateServer.c_str(), PACKAGE_VERSION_FILE, getCurrentTime());
	CCHttpRequest* request = new CCHttpRequest();
	request->setUrl(pUrl->getCString());
	request->setRequestType(CCHttpRequest::kHttpGet);
	request->setResponseCallback(this, httpresponse_selector(CDownloadPackage::requestVersionInfoCallBack));
	CCHttpClient::getInstance()->send(request);
	request->release();
}
开发者ID:54993306,项目名称:Classes,代码行数:11,代码来源:CDownloadPackage.cpp

示例15: CCHttpRequest

void MyHttpRequest::doGet()
{
	m_isCompleted=false;
	m_responseData="";
	CCHttpRequest* request = new CCHttpRequest();
	request->setUrl("baidu.com");
	request->setRequestType(CCHttpRequest::kHttpGet);
	request->setResponseCallback(this, callfuncND_selector(MyHttpRequest::onHttpRequestCompleted));
	CCHttpClient::getInstance()->send(request); 
	request->release();
}
开发者ID:pzhifeng,项目名称:client-main,代码行数:11,代码来源:MyHttpRequest.cpp


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