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


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

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


在下文中一共展示了CCHttpRequest::setTag方法的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: 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

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

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

示例7: touchUpInside

void LoginLayer::touchUpInside(CCObject* pSender, CCControlEvent event) {
//	CCLog("size(%d, %d)", strlen(m_pNameBox->getText()),
//			strlen(m_pPasswordBox->getText()));

	if (strlen(m_pNameBox->getText()) > 0
			&& strlen(m_pPasswordBox->getText()) > 0) {
		string str;
		str.append(m_pNameBox->getText());
		CCUserDefault::sharedUserDefault()->setStringForKey("UserName",
				m_pNameBox->getText());
		CCUserDefault::sharedUserDefault()->flush();
		CCDirector::sharedDirector()->replaceScene(
				CCTransitionFade::create(0.5, HelloWorld::scene()));
	}

	CCHttpRequest* request = new CCHttpRequest();
	const char *uname = m_pNameBox->getText();
	string url = "127.0.0.1:80/index.html?";

	string postData = "username=";
	postData.append(uname);
	postData.append("&password=");
	postData.append(m_pPasswordBox->getText());

	bool requestType_is_get = true;
	if (requestType_is_get) {
		request->setUrl((url + postData).c_str());
		CCLOG("GetType data : %s", (url + postData).c_str());
		request->setRequestType(CCHttpRequest::kHttpGet);
		request->setTag("GET test");
	} else {
		request->setUrl(url.c_str());
		request->setRequestType(CCHttpRequest::kHttpPost);
		request->setRequestData(postData.c_str(), postData.size());
		CCLOG("GetType data : %s", postData.c_str());
		request->setTag("POST test");
	}
	request->setResponseCallback(this,
			httpresponse_selector(LoginLayer::onHttpRequestCompleted));
	CCHttpClient::getInstance()->send(request);
	request->release();	
	m_pSendButton->setEnabled(false);
}
开发者ID:SpiritRain,项目名称:sudosudoku,代码行数:43,代码来源:LoginScene.cpp

示例8: BottonOKClicked

void LoginLayer::BottonOKClicked( CCObject* pSender )
{
    CCHttpRequest* request = new CCHttpRequest();
    std::string url = "http://127.0.0.1:8000/member/" + std::string(m_pTextField->getString());
    request->setUrl(url.c_str());
    request->setRequestType(CCHttpRequest::kHttpGet);
    request->setResponseCallback(this, httpresponse_selector(LoginLayer::onHttpRequestCompleted));
    request->setTag("GET test1");
    CCHttpClient::getInstance()->send(request);
    request->release();
}
开发者ID:hanxu101,项目名称:projectx,代码行数:11,代码来源:SceneLogin.cpp

示例9: btncallback

void TestLayer::btncallback( CCObject* pSender )
{
	bool requestType_is_get=true;//采用get方式或者post方式
	if (requestType_is_get)
	{
		CCHttpRequest* request = new CCHttpRequest();//创建请求对象
		string str1 = "127.0.0.1:80/index.html?";
		string str2 = p_User_EditBox->getText();//获取username编辑框内容
		string str3 = p_Psw_EditBox->getText();//获取password编辑框内容
		string struser="username=";
		string strpsw="&password=";
		str1=str1+struser+str2+strpsw+str3;
		request->setUrl(str1.c_str());//设置请求的url,username和password已经包含在url中
		request->setRequestType(CCHttpRequest::kHttpGet);//设置为Get模式
		request->setResponseCallback(this, httpresponse_selector(TestLayer::onHttpRequestCompleted));//设置响应的回调
		request->setTag("GET test");
		CCHttpClient::getInstance()->send(request);//发送请求
		request->release();//释放请求
	}
	else
	{
		CCHttpRequest* request = new CCHttpRequest();//创建请求对象
		string str1 = "127.0.0.1:80/index.html";
		string str2 = p_User_EditBox->getText();
		string str3 = p_Psw_EditBox->getText();
		string struser="username=";
		string strpsw="&password=";
		str2=struser+str2+strpsw+str3;
  
		request->setUrl(str1.c_str());//设置请求的url,只是请求页面的url,并不包含username和password
		request->setRequestType(CCHttpRequest::kHttpPost);//设置为Post模式
		request->setResponseCallback(this, httpresponse_selector(TestLayer::onHttpRequestCompleted));//设置响应的回调
  
		const char* postData = str2.c_str();
		request->setRequestData(postData, strlen(postData));//设置请求数据,也就是username和password
		
		request->setTag("POST test");
		CCHttpClient::getInstance()->send(request);//发送请求
		request->release();//释放请求
	}
}
开发者ID:Caimy,项目名称:Cocos2d-x,代码行数:41,代码来源:TestLayer.cpp

示例10: onMenuPutTestClicked

void HttpClientTest::onMenuPutTestClicked(CCObject *sender)
{
    // test 1
    {
        CCHttpRequest* request = new CCHttpRequest();
        request->setUrl("http://httpbin.org/put");
        request->setRequestType(CCHttpRequest::kHttpPut);
        request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));

        // write the post data
        const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetworkTest";
        request->setRequestData(postData, strlen(postData));

        request->setTag("PUT test1");
        CCHttpClient::getInstance()->send(request);
        request->release();
    }

    // test 2: set Content-Type
    {
        CCHttpRequest* request = new CCHttpRequest();
        request->setUrl("http://httpbin.org/put");
        request->setRequestType(CCHttpRequest::kHttpPut);
        std::vector<std::string> headers;
        headers.push_back("Content-Type: application/json; charset=utf-8");
        request->setHeaders(headers);
        request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));

        // write the post data
        const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetworkTest";
        request->setRequestData(postData, strlen(postData));

        request->setTag("PUT test2");
        CCHttpClient::getInstance()->send(request);
        request->release();
    }

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

示例11: NetHttpReqRaw

	void NetHttpReqRaw(string url,string data,string type,string tag)
	{
		CCHttpRequest* request = new CCHttpRequest();
		request->setUrl(url.c_str());
		request->setTag(tag.c_str());
		if(type=="post"){
			request->setRequestType(cocos2d::extension::CCHttpRequest::kHttpPost);
			request->setRequestData(data.c_str(),data.length());
		}else{
			request->setRequestType(cocos2d::extension::CCHttpRequest::kHttpGet);
		}
		CCHttpClient::getInstance()->send(request);
	}
开发者ID:liyonghelpme,项目名称:fenshencocos2dx,代码行数:13,代码来源:Game.cpp

示例12: send

void XMLHttpRequest::send(std::string param){
    readyState = 1;
    CCHttpRequest *request = new CCHttpRequest();
    request->setUrl(reqUrl.c_str());
    request->setRequestType(CCHttpRequest::kHttpGet);
    
//    std::vector<std::string> headers;
//    headers.push_back("Content-Type: application/json; charset=utf-8");
//    request->setHeaders(headers);
    
    request->setResponseCallback(this, callfuncND_selector(XMLHttpRequest::onHttpRequestCompleted));
    request->setRequestData(param.c_str(), strlen(param.c_str()));
    request->setTag("wx");
    CCHttpClient::getInstance()->send(request);
    request->release();
    readyState = 3;
}
开发者ID:zj831007,项目名称:jsbtest,代码行数:17,代码来源:XMLHttpRequest.cpp

示例13: addFriendRequest

void AddFriendScene::addFriendRequest(std::string &targetUser)
{
	CCHttpRequest *request = new CCHttpRequest();
	request->setRequestType(CCHttpRequest::kHttpGet);
	request->setResponseCallback(this,httpresponse_selector(AddFriendScene::requestFinishedCallback));
	request->setTag("102");
    
	string _strUrl = CompleteUrl(URL_FRIEND_ADD_NEW);
	_strUrl.append(CCUserDefault::sharedUserDefault()->getStringForKey("userinfo"));
	_strUrl.append("/" + targetUser);

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

	CCHttpClient *client = CCHttpClient::getInstance();
	client->send(request);
    
	request->release();
}
开发者ID:crazyit,项目名称:iGame,代码行数:18,代码来源:AddFriendScene.cpp

示例14: onMenuPostTestClicked

void HttpClientTest::onMenuPostTestClicked(cocos2d::CCObject *sender)
{
    CCHttpRequest* request = new CCHttpRequest();
    request->setUrl("http://www.httpbin.org/post");
    request->setRequestType(CCHttpRequest::kHttpPost);
    request->setResponseCallback(this, callfuncND_selector(HttpClientTest::onHttpRequestCompleted));
    
    // write the post data
    const char* postData = "visitor=cocos2d&TestSuite=Extensions Test/NetowrkTest";
    request->setRequestData(postData, strlen(postData)); 
    
    request->setTag("POST test");
    CCHttpClient::getInstance()->send(request);
    request->release();
    
    // waiting
    m_labelStatusCode->setString("waiting...");
}
开发者ID:acc85,项目名称:cocos2d-x,代码行数:18,代码来源:HttpClientTest.cpp

示例15: onMenuPostBinaryTestClicked

void HttpClientTest::onMenuPostBinaryTestClicked(cocos2d::CCObject *sender)
{
    CCHttpRequest* request = new CCHttpRequest();
    request->setUrl("http://httpbin.org/post");
    request->setRequestType(CCHttpRequest::kHttpPost);
    request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));
    
    // write the post data
    char postData[22] = "binary=hello\0\0cocos2d";  // including \0, the strings after \0 should not be cut in response
    request->setRequestData(postData, 22); 
    
    request->setTag("POST Binary test");
    CCHttpClient::getInstance()->send(request);
    request->release();
    
    // waiting
    m_labelStatusCode->setString("waiting...");
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:18,代码来源:HttpClientTest.cpp


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