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


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

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


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

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

示例2: getPostRequestByUrlAndData

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

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

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

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

示例6: send

	void send(const char* buffer = NULL){
		if(m_request != NULL){
			if(NULL != buffer){
				m_request->setRequestData(buffer, sizeof buffer);
			}
			m_request->setHeaders(m_headers);
			CCHttpClient::getInstance()->send(m_request);
			CC_SAFE_RELEASE_NULL(m_request);
			m_headers.clear();
		}
	};
开发者ID:akira-cn,项目名称:cocos2dx-cqwrap,代码行数:11,代码来源:cqwrap_httprequest_manual.cpp

示例7: _loadLeaderboard

void OnlineController::_loadLeaderboard(float)
{
    CCLog("== loading leaderboard");
    CCHttpRequest* request = new CCHttpRequest;
    std::string adr = m_server + "/get";
    request->setUrl(adr.c_str());
    request->setRequestData("", 1);
    request->setRequestType(CCHttpRequest::kHttpGet);
    request->setResponseCallback(this, httpresponse_selector(OnlineController::_onLeaderboardLoaded));
    CCHttpClient::getInstance()->send(request);
}
开发者ID:timur-losev,项目名称:HungryChameleon,代码行数:11,代码来源:OnlineController.cpp

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

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

示例10: unlockHeroHTTP

void RankScene::unlockHeroHTTP(int _HeroIndex){
    
    MessageBox = AsMessageBox::createMessageBox("通信中,请稍候", 1, 0);
    MessageBox->setPosition(CCPointZero);
    addChild(MessageBox,1000);
    
    CCHttpRequest* request = new CCHttpRequest();
    request->setUrl("http://115.29.168.228/roles");
    request->setRequestType(CCHttpRequest::kHttpPost);
    request->setResponseCallback(this, callfuncND_selector(RankScene::unlockHeroRequestCompleted));
    string postDataStr = "role[avatar_id]=" + int2string(_HeroIndex) + "&role[level]=" + int2string(0) + "&token=" + MainUser->UserTokenStr;
    request->setRequestData(postDataStr.c_str(), postDataStr.length());
    CCHttpClient::getInstance()->send(request);
    request->release();
}
开发者ID:nooboracle,项目名称:ForTest,代码行数:15,代码来源:LevelUpHeroHTTP.cpp

示例11: doSend

void CommandManager::doSend(Command* command)
{
    m_currentCommand = command;
    
    CCHttpRequest* request = new CCHttpRequest();
    
    request->setRequestType(CCHttpRequest::kHttpPost);
    request->setUrl(Command::URL.c_str());
    
    const vector<char>& data = command->getData();
    
    request->setRequestData(&data[0], data.size());
    request->setResponseCallback(this, httpresponse_selector(CommandManager::onResponse));
    
    CCHttpClient::getInstance()->send(request);
}
开发者ID:newcl,项目名称:boom,代码行数:16,代码来源:CommandManager.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: 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

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


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