本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
};
示例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);
}
示例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...");
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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...");
}
示例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...");
}
示例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);
}