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


C++ CCHttpRequest::setResponseCallback方法代码示例

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


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

示例1: onMenuDeleteTestClicked

void HttpClientTest::onMenuDeleteTestClicked(CCObject *sender)
{
    // test 1
    {
        CCHttpRequest* request = new CCHttpRequest();
        request->setUrl("http://just-make-this-request-failed.com");
        request->setRequestType(CCHttpRequest::kHttpDelete);
        request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));
        request->setTag("DELETE test1");
        CCHttpClient::getInstance()->send(request);
        request->release();
    }

    // test 2
    {
        CCHttpRequest* request = new CCHttpRequest();
        request->setUrl("http://httpbin.org/delete");
        request->setRequestType(CCHttpRequest::kHttpDelete);
        request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));
        request->setTag("DELETE test2");
        CCHttpClient::getInstance()->send(request);
        request->release();
    }

    // waiting
    m_labelStatusCode->setString("waiting...");
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:27,代码来源:HttpClientTest.cpp

示例2: ProfileTimer

void RequestTopaz::ProfileTimer(float f)
{
    // 프로필 사진 왼쪽 위 지점과 스크롤뷰 위치를 비교한다.
    // 음수가 되면, 아래에 있던 프로필이 스크롤뷰에 보이기 시작했다는 의미 -> 프로필 로딩 시작.
    CCPoint p;
    float h;
    int numOfList = friendList.size();
    for (int i = 0 ; i < friendList.size() ; i++)
    {
        ProfileSprite* psp = ProfileSprite::GetObj(friendList[i]->GetImageUrl());
        if (psp->IsLoadingStarted() || psp->IsLoadingDone())
            continue;
        
        if (spriteClassScroll == NULL)
            return;
        p = ((CCSprite*)spriteClassScroll->FindSpriteByTag(-888*(numOfList-i)))->convertToNodeSpace(scrollView->getPosition());
        h = friendList[i]->GetProfile()->getContentSize().height;
        
        if (p.y - h < 0)
        {
            psp->SetLoadingStarted(true);
            
            char tag[6];
            CCHttpRequest* req = new CCHttpRequest();
            req->setUrl(psp->GetProfileUrl().c_str());
            req->setRequestType(CCHttpRequest::kHttpPost);
            req->setResponseCallback(this, httpresponse_selector(RequestTopaz::onHttpRequestCompletedNoEncrypt));
            sprintf(tag, "%d", i);
            req->setTag(tag);
            CCHttpClient::getInstance()->send(req);
            req->release();
        }
    }
}
开发者ID:playdandi,项目名称:CocoDrawingMagic,代码行数:34,代码来源:RequestTopaz.cpp

示例3: doSearchFriend

void AddFriendScene::doSearchFriend()
{
	std::string sSearchField(m_txtSearchField->getText());
	sSearchField = trimRight(sSearchField);

	if (sSearchField.empty()) {
		CCMessageBox("搜索内容不能为空","ERROR");
		return;
	}

	this->ShowLoadingIndicator("");

	CCHttpRequest *request = new CCHttpRequest();
	request->setRequestType(CCHttpRequest::kHttpGet);
	request->setResponseCallback(this,httpresponse_selector(AddFriendScene::requestFinishedCallback));
	request->setTag("101");
    
	string _strUrl = CompleteUrl(URL_FRIEND_SEARCH);
	_strUrl.append(CCUserDefault::sharedUserDefault()->getStringForKey("userinfo"));
	_strUrl.append("/");
	_strUrl.append(sSearchField);

	request->setUrl(_strUrl.c_str());

	CCHttpClient *client = CCHttpClient::getInstance();
	client->send(request);

	request->release();
}
开发者ID:crazyit,项目名称:iGame,代码行数:29,代码来源:AddFriendScene.cpp

示例4: LogInHTTP

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

示例5: downloadPhoto

void EziSocialObject::downloadPhoto(CCLayer* parentNode, const char *fbID, const char *fbURL, const char* filename, bool forceDownloadFromServer)
{
    
    if (forceDownloadFromServer == false) // Check if local copy exist
    {
        std::string file = cocos2d::CCFileUtils::sharedFileUtils()->getWritablePath().append(filename);
        bool fileExist = cocos2d::CCFileUtils::sharedFileUtils()->isFileExist(file);
        
        if (fileExist)
        {
            internalUserPhotoCallback(file.c_str(), fbID);
            return;
        }
    }
    
    // If we have reached here; that means local copy does not exsist. Download a new one.
    
    CCHttpRequest* request = new CCHttpRequest();
    request->setUrl(fbURL);
    request->setRequestType(CCHttpRequest::kHttpGet);
    
    request->setResponseCallback(parentNode, httpresponse_selector(EziSocialObject::onHttpRequestCompleted));
    
    request->setTag(filename);
    
    CCHttpClient::getInstance()->send(request);
    request->release();
}
开发者ID:KevinLion,项目名称:EziSocial-Plugin,代码行数:28,代码来源:EziSocialObject.cpp

示例6: rechargeOnClick

void QimiAlipayView::rechargeOnClick(cocos2d::CCNode* pSender, cocos2d::extension::CCControlEvent* pCCControlEvent)
{
    m_money = atoi(m_pEditName->getText());
    CCHttpRequest* request = new CCHttpRequest();
    request->setUrl("http://www.qimi.com/platform/addOrder.php");
    request->setRequestType(CCHttpRequest::kHttpPost);
    request->setResponseCallback(this, httpresponse_selector(QimiAlipayView::onLoadOrderSucssful));
    
    char sign[255];
    sprintf(sign, "%s%d%s",
            m_uId.c_str(),
            m_sId,
            m_key.c_str());
    QimiMD5 md5;
    md5.update(sign);
    
    CCLog("md5str==%s",sign);
    std::string md5tolower = md5.toString();
    
    CCString* postDataStr = CCString::createWithFormat("uId=%s&sId=%d&sign=%s&money=%d&orderType=alipay&type=0", m_uId.c_str(), m_sId, md5tolower.c_str(), m_money);
    CCLog("addOrder string ===%s", postDataStr->getCString());
    const char* postData =postDataStr->getCString();
    request->setRequestData(postData, strlen(postData));
    
    request->setTag("POST test1");
    CCHttpClient::getInstance()->send(request);
    request->release();
    
    RequestLoadingView* mask = RequestLoadingView::create();
    mask->setTag(100000);
    this->addChild(mask);
    
}
开发者ID:BenVim,项目名称:IsmoleSDK,代码行数:33,代码来源:QimiAlipayView.cpp

示例7: 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

示例8: getHeroInformationHTTP

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

示例9: 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

示例10: onMenuGetTestClicked

void HttpClientTest::onMenuGetTestClicked(cocos2d::CCObject *sender)
{    
    // test 1
    {
        CCHttpRequest* request = new CCHttpRequest();
        request->setUrl("http://just-make-this-request-failed.com");
        request->setRequestType(CCHttpRequest::kHttpGet);
        request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));
        request->setTag("GET test1");
        CCHttpClient::getInstance()->send(request);
        request->release();
    }
    
    // test 2
    {
        CCHttpRequest* request = new CCHttpRequest();
        // required fields
        request->setUrl("http://httpbin.org/ip");
        request->setRequestType(CCHttpRequest::kHttpGet);
        request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));
        // optional fields                            
        request->setTag("GET test2");
    
        CCHttpClient::getInstance()->send(request);
    
        // don't forget to release it, pair to new
        request->release();
    }
    
    // test 3   
    {
        CCHttpRequest* request = new CCHttpRequest();
        request->setUrl("http://httpbin.org/get");
        request->setRequestType(CCHttpRequest::kHttpGet);
        request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));
        request->setTag("GET test3");
        CCHttpClient::getInstance()->send(request);
        request->release();
    }
        
    // waiting
    m_labelStatusCode->setString("waiting...");
 
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:44,代码来源:HttpClientTest.cpp

示例11: sendData

void YHHttpClient::sendData(YHByteArray * bytes, CCHttpRequest::HttpRequestType type)
{
	CCHttpRequest * request = new CCHttpRequest();
	request->setRequestType(type);
	request->setUrl(m_url.c_str());
	request->setRequestData((const char *)bytes->getBuffer(), bytes->readableBytes());
	request->setResponseCallback(this, httpresponse_selector(YHHttpClient::onResponseCallBack));
	m_httpClient->send(request);
	request->release();
}
开发者ID:QiuleiWang,项目名称:cocos2d-x-2.x-utils,代码行数:10,代码来源:YHHttpClient.cpp

示例12: _discoverServer

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

示例13: getServerTime

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

示例14: sendRequest

void Http::sendRequest(const char *data, unsigned length)
{
    CCHttpRequest *pRequest = new CCHttpRequest();
    pRequest->setUrl(mURL.c_str());
    pRequest->setRequestType(CCHttpRequest::kHttpPost);
    pRequest->setResponseCallback(this, httpresponse_selector(Http::recvResponse));
    pRequest->setRequestData(data, length);
    CCHttpClient::getInstance()->send(pRequest);
    pRequest->release();
}
开发者ID:kun-g,项目名称:client,代码行数:10,代码来源:Http.cpp

示例15: getRankHTTP

void RankScene::getRankHTTP(){
    
    CCHttpRequest* request = new CCHttpRequest();
    string UrlData = "http://115.29.168.228/winning_boards/" + int2string(tibaoType) + "/whereami?token=" + MainUser->UserTokenStr;
    request->setUrl(UrlData.c_str());
    request->setRequestType(CCHttpRequest::kHttpGet);
    request->setResponseCallback(this, callfuncND_selector(RankScene::getRankRequestCompleted));
    CCHttpClient::getInstance()->send(request);
    request->release();
}
开发者ID:nooboracle,项目名称:ForTest,代码行数:10,代码来源:RankListHTTP.cpp


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