本文整理汇总了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 );
}
}
示例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);
}
}
示例3: httpRequestLua
CCHttpRequest* CCNetwork::httpRequestLua(LUA_FUNCTION listener,
const char* url,
CCHttpRequestMethod method)
{
CCHttpRequest* request = CCHttpRequest::createWithUrlLua(listener, url, method);
request->start();
return request;
}
示例4: CCHttpRequest
CCHttpRequest* CHttpServer::getGetRequestByUrl(const char* pUrl)
{
CCHttpRequest* pRequest = new CCHttpRequest();
pRequest->setUrl(pUrl);
pRequest->setRequestType(CCHttpRequest::kHttpGet);
addDefaultHeaders(pRequest);
return pRequest;
}
示例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));
};
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}