本文整理汇总了C++中CCHttpResponse::getErrorBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CCHttpResponse::getErrorBuffer方法的具体用法?C++ CCHttpResponse::getErrorBuffer怎么用?C++ CCHttpResponse::getErrorBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCHttpResponse
的用法示例。
在下文中一共展示了CCHttpResponse::getErrorBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteFileFinished
void ParseFile::deleteFileFinished(CCNode* sender, void* param)
{
bool success = false;
ParseError* error = new ParseError();
CCHttpResponse* response = (CCHttpResponse*)param;
if (response->getResponseCode() == 200)
{
success = true;
}
else
{
if (strlen(response->getErrorBuffer()) > 0)
{
error->SetError(response->getErrorBuffer());
}
else
{
std::vector<char>* responseData = response->getResponseData();
responseData->push_back('\0');
error->SetError(&responseData->front());
}
}
this->deleteFileCompleted(success, error);
delete error;
}
示例2: downloadFileFinished
void ParseFile::downloadFileFinished(CCNode* sender, void* param)
{
CCString* savePathName = 0;
ParseError* error = new ParseError();
CCHttpResponse* response = (CCHttpResponse*)param;
if (response->getResponseCode() == 200)
{
FILE* file = 0;
const char* errorMsg = 0;
savePathName = (CCString*)response->getHttpRequest()->getUserData();
std::vector<char>* responseData = response->getResponseData();
do
{
file = fopen(savePathName->getCString(), "wb");
if (file == 0)
{
errorMsg = "error open file!";
break;
}
size_t writeLen = fwrite(&responseData->front(), 1, responseData->size(), file);
if (writeLen != responseData->size())
{
errorMsg = "error write file!";
break;
}
}while(0);
if (file)
{
fclose(file);
}
if (errorMsg)
{
error->SetError(errorMsg);
}
}
else
{
if (strlen(response->getErrorBuffer()) > 0)
{
error->SetError(response->getErrorBuffer());
}
else
{
std::vector<char>* responseData = response->getResponseData();
responseData->push_back('\0');
error->SetError(&responseData->front());
}
}
this->downloadFileCompleted(savePathName?savePathName->getCString():0, error);
savePathName = (CCString*)response->getHttpRequest()->getUserData();
savePathName->release();
delete error;
}
示例3: onHttpRequestCompleted
void GameState::onHttpRequestCompleted(CCNode* sender,void *data)
{
CCHttpResponse *response = (CCHttpResponse*)data;
if(!response)
return;
if( NULL != strlen(response->getHttpRequest()->getTag()))
{
CCLog("%s complete.",response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
CCLog("response code : %d",statusCode);
if(!response->isSucceed())
{
CCLog("response failed");
CCLog("errorbuffer: %s",response->getErrorBuffer());
return;
}
std::vector<char>* buffer = response->getResponseData();
char str[200] = {""};
unsigned int i;
for(i=0;i<buffer->size();i++)
{
str[i] = (*buffer)[i];
}
str[i] = '\0';
CCLog("%s",str);
}
示例4: onHttpRequestCompleteHandler
void DataRequest::onHttpRequestCompleteHandler(cocos2d::CCNode *pSender, void *pObj)
{
CCHttpResponse *pResponse = (CCHttpResponse* )pObj;
if (!pResponse)
{
return;
}
if (pResponse->isSucceed())
{
std::string responseData;
std::vector<char> *buffer = pResponse->getResponseData();
char buff[24];
for (unsigned int i = 0; i < buffer->size(); i ++)
{
sprintf(buff, "%c", (*buffer)[i]);
responseData.append(buff);
}
//CCLog(responseData.c_str());
if (m_pTarget && m_requestAction)
{
(m_pTarget->*m_requestAction)(RequestStatusSucceed, responseData);
}
}
else
{
const char *error = pResponse->getErrorBuffer();
if (m_pTarget && m_requestAction)
{
(m_pTarget->*m_requestAction)(RequestStatusError, error);
}
}
}
示例5: requestFinishedCallback
void ChatLayer::requestFinishedCallback(CCNode* pSender,void *data)
{
CCHttpResponse *response = (CCHttpResponse*)data;
if(response==NULL)
{
return;
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
CCLOG(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
if (!response->isSucceed())
{
CCLog("response failed");
CCLog("error buffer: %s", response->getErrorBuffer());
return;
}
std::vector<char> *buffer = response->getResponseData();
std::string content(buffer->begin(),buffer->end());
XMLParser *xmlParser = XMLParser::parseWithString(content.c_str());
CCLOG("%s",xmlParser->getString("content")->getCString());
// parseJson();
}
示例6: uploadFileContentFinished
void ParseFile::uploadFileContentFinished(CCNode* sender, void* param)
{
FileInfo* result = 0;
ParseError* error = new ParseError();
CCHttpResponse* response = (CCHttpResponse*)param;
if (response->getResponseCode() == 201)
{
rapidjson::Document retValue;
if(ParseJson::FromByteArray(*response->getResponseData(), retValue, error))
{
if (retValue.HasMember("url"))
{
result = new FileInfo(retValue["url"].GetString(), retValue["name"].GetString());
}
}
if (result == 0)
{
std::vector<char>* responseData = response->getResponseData();
responseData->push_back('\0');
error->SetError(error->GetError() + "data:" + &responseData->front());
}
}
else
{
if (strlen(response->getErrorBuffer()) > 0)
{
error->SetError(response->getErrorBuffer());
}
else
{
std::vector<char>* responseData = response->getResponseData();
responseData->push_back('\0');
error->SetError(&responseData->front());
}
}
this->uploadFileContentCompleted(result, error);
delete error;
}
示例7: responseCallback
void responseCallback(cocos2d::CCNode *sender, void *data){
CCHttpResponse *response = (CCHttpResponse*)data;
if (!response)
{
CCLog("no response...");
return;
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d", statusCode);
CCLOG("response code: %d", statusCode);
if (!response->isSucceed())
{
CCLOG("response failed");
CCLOG("error buffer: %s", response->getErrorBuffer());
JsonData* msg = new JsonData();
(*msg)["data"] = response->getErrorBuffer();
PROXY_FIRE("error", msg);
CC_SAFE_DELETE(msg);
return;
}
// dump data
std::vector<char> *buffer = response->getResponseData();
//std::string path = CCFileUtils::sharedFileUtils()->getWriteablePath();
std::string buf(buffer->begin(),buffer->end());
JsonData* msg = new JsonData();
(*msg)["data"] = buf.c_str();
PROXY_FIRE("complete", msg);
CC_SAFE_DELETE(msg);
};
示例8: onHttpRequestCompleted
void EziSocialObject::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
{
CCHttpResponse* response = (CCHttpResponse*)data;
if (!response)
{
CCLOG("[EziSocial Error]: No Response");
}
if (0 != strlen(response->getHttpRequest()->getTag()))
{
//CCLog("%s completed", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
if (!response->isSucceed())
{
CCLog("[EziSocial Error]: response failed");
CCLog("[EziSocial Error]: error buffer: %s", response->getErrorBuffer());
return;
}
// Dump the data
std::vector<char> *buffer = response->getResponseData();
// Create the CCSprite from data dump...
CCImage * img=new CCImage();
img->initWithImageData(&(buffer->front()), buffer->size());
// Save file for resue.
std::string writablePath = CCFileUtils::sharedFileUtils()->getWritablePath();
writablePath.append(response->getHttpRequest()->getTag());
img->saveToFile(writablePath.c_str());
delete img;
const char* userID = "";
std::string tagString = "";
tagString.append(response->getHttpRequest()->getTag());
std::vector< std::string > strings = EziSocialObject::tokenizeStr(tagString, "_");
userID = strings[0].c_str();
internalUserPhotoCallback(writablePath.c_str(), userID);
}
示例9:
void S411FeedBack::onPostFinished(CCNode *node,void *data)
{
AppDelegate::loadingLabel ->setString("");
_menu->setEnabled(true);
CCHttpResponse *response = (CCHttpResponse*)data;
if (!response)
{
return;
}
int s=response->getHttpRequest()->getRequestType();
CCLOG("request type %d",s);
if (0 != strlen(response->getHttpRequest()->getTag()))
{
CCLOG("%s ------>oked", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
CCLOG("response code: %d", statusCode);
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
CCLOG("statusString");
if (!response->isSucceed())
{
CCLOG("response failed");
CCLOG("error buffer: %s", response->getErrorBuffer());
AppDelegate::loadingLabel->setString("提交失败");
this->schedule(schedule_selector(S411FeedBack::time),1.0f,false,0.0);
return;
}
//上面这些都是一些判断是否请求成功,下面这个是获得的请求数据
std::vector<char> *buffer = response->getResponseData();
CCLOG("Http Test, dump data: ");
for (unsigned int i = 0; i < buffer->size(); i++)
{
CCLOG("%c", (*buffer)[i]);//这里打印从服务器返回的数据
}
CCLOG("\n");
AppDelegate::loadingLabel->setString("提交成功");
this->schedule(schedule_selector(S411FeedBack::time),1.0f,false,0.0);
}
示例10: onHttpRequestCompleted
void InGameScene::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
{
CCHttpResponse *response = (CCHttpResponse*)data;
if (!response)
{
return;
}
// You can get original request type from: response->request->reqType
if (0 != strlen(response->getHttpRequest()->getTag()))
{
CCLog("%s completed", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
//m_labelStatusCode->setString(statusString);
CCLog("response code: %d", statusCode);
if (!response->isSucceed())
{
CCLog("response failed");
CCLog("error buffer: %s", response->getErrorBuffer());
return;
}
// dump data
std::vector<char> *buffer = response->getResponseData();
std::string s = "";
bool isDataStarted = false;
for (unsigned int i = 0; i < buffer->size(); i++)
{
if( isDataStarted == false && !isspace((*buffer)[i]) )
isDataStarted = true;
if( isDataStarted == false) continue;
s += (*buffer)[i];
}
CCLog("%s", s.data() );
CCLog("\n");
if( strcmp(response->getHttpRequest()->getTag(), "URL_CREATE_ANIMAL") == 0)
{
string szAnimalKey = s;
CCLog("InGameScene::onHttpRequestCompleted-%s : %s", response->getHttpRequest()->getTag(), szAnimalKey.data() );
}
}
示例11: onHttpRequestCompleted
void ShopItemInfoFromServer::onHttpRequestCompleted(CCNode *node,void *data)
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
CCHttpResponse *response = (CCHttpResponse*)data;
if (!response)
{
return;
}
if (!response->isSucceed())
{
CCLog("response failed");
CCLog("error buffer: %s", response->getErrorBuffer());
return;
}
#endif
}
示例12: onHttpRequestCompleted
void MyHttpRequest::onHttpRequestCompleted(CCNode *sender,void *data)
{
m_isCompleted=true;
CCHttpResponse *response = (CCHttpResponse*)data;
if (!response)
{
return;
}
int s=response->getHttpRequest()->getRequestType();
CCLog("request type %d",s);
if (0 != strlen(response->getHttpRequest()->getTag()))
{
CCLog("%s ------>oked", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
CCLog("response code: %d", statusCode);
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
CCLog(statusString);
if (!response->isSucceed())
{
CCLog("response failed");
CCLog("error buffer: %s", response->getErrorBuffer());
return;
}
std::vector<char> *buffer = response->getResponseData();
printf("Http Test, dump data: ");
for (unsigned int i = 0; i < buffer->size(); i++)
{
//CCLog("%c", (*buffer)[i]);//这里打印从服务器返回的数据
m_responseData.push_back((*buffer)[i]);
}
CCLog("m_responseData:%s",m_responseData.c_str());
printf("\n");
}
示例13: onHttpRequestCompleted
void HttpClientTest::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
{
CCHttpResponse *response = (CCHttpResponse*)data;
if (!response)
{
return;
}
// You can get original request type from: response->request->reqType
if (0 != strlen(response->getHttpRequest()->getTag()))
{
CCLog("%s completed", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
m_labelStatusCode->setString(statusString);
CCLog("response code: %d", statusCode);
if (!response->isSucceed())
{
CCLog("response failed");
CCLog("error buffer: %s", response->getErrorBuffer());
return;
}
// dump data
std::vector<char> *buffer = response->getResponseData();
printf("Http Test, dump data: ");
for (unsigned int i = 0; i < buffer->size(); i++)
{
printf("%c", (*buffer)[i]);
}
printf("\n");
}
示例14: requestFinishHandler
void SGHttpClient::requestFinishHandler(CCNode *sender, void *data)
{
CCHttpResponse *response = (CCHttpResponse*)data;
if (!response)
{
return;
}
int statusCode = response->getResponseCode();
CCLog("response code: %d", statusCode);
if (!response->isSucceed())
{
SGMainManager::shareMain()->getMainScene()->plat->removeConnection();
// 弹框
if (_delegate)
{
_delegate->requestFailed();
}
CCLog("response failed");
CCLog("error buffer: %s", response->getErrorBuffer());
return;
}
if (0 != strlen(response->getHttpRequest()->getTag()))
{
const char *responseTag = response->getHttpRequest()->getTag();
CCLog("%s completed", responseTag);
int rt = atoi(responseTag);
std::vector<char> *buffer = response->getResponseData();
int bufferSize = buffer->size();
char *bufferchar = new char[bufferSize];
std::copy(buffer->begin(), buffer->end(), bufferchar);
switch (rt)
{
case MSG_HTTP_FAST_LOGIN:
{
this->fastLoginListener(bufferchar);
break;
}
case MSG_HTTP_LOGIN:
{
this->loginListener(bufferchar);
break;
}
case MSG_HTTP_REGISTER:
{
this->registerListener(bufferchar);
break;
}
case MSg_HTTP_SERVERLIST:
{
this->serverListListener(bufferchar);
break;
}
case MSG_HTTP_BING:
{
bindListener(bufferchar);
break;
}
case MSG_HTTP_PASSWORD:
{
passwordListener(bufferchar);
break;
}
case MSg_HTTP_LASTESTSERVER:
{
getlastestServer(bufferchar);
break;
}
case MSG_HTTP_UPDATE_SERVER_STATE:
{
updateSelectServerResponse(bufferchar);
}
break;
case MSG_HTTP_GET_CHANNEL_USER_ID:
{
rspGetChannelUserId(bufferchar);
}
break;
default:
break;
}
}
CCUserDefault::sharedUserDefault()->setBoolForKey("pvp_tran", false);
SGMainManager::shareMain()->getMainScene()->plat->removeConnection();
}
示例15: onHttpRequestCompleted
void LoadingScene::onHttpRequestCompleted(cocos2d::CCNode *sender, void *data)
{
CCLog("LoadingScene::onHttpRequestCompleted");
CCHttpResponse *response = (CCHttpResponse*)data;
if (!response)
{
return;
}
// You can get original request type from: response->request->reqType
if (0 != strlen(response->getHttpRequest()->getTag()))
{
CCLog("%s completed", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
//m_labelStatusCode->setString(statusString);
CCLog("response code: %d", statusCode);
if (!response->isSucceed())
{
CCLog("response failed");
CCLog("error buffer: %s", response->getErrorBuffer());
return;
}
// dump data
std::vector<char> *buffer = response->getResponseData();
std::string s;
bool isDataStarted = false;
for (unsigned int i = 0; i < buffer->size(); i++)
{
if( isDataStarted == false && !isspace((*buffer)[i]) )
isDataStarted = true;
if( isDataStarted == false) continue;
s += (*buffer)[i];
}
CCLog("LoadingScene::onHttpRequestCompleted : buffer=%s", s.data() );
if(strcmp(response->getHttpRequest()->getTag(), "URL_RECEIVE_ANIMALS") == 0)
{
labelLoading->setString("동물들과 교감하는중...");
vector<ANIMALINFO> animalList;
CCLog("URL_RECEIVE_ANIMALS: it comes %d", s.length());
bool isAlreadyExist = false;
map<int, Animal*>* pList = pData->getAnimalsByAccount(SceneManager::sharedSceneManager()->getUserAccountKey());
if( pList != NULL )
isAlreadyExist = true;
while (s.length() != 0)
{
int delimIndex = s.find('|');
string oneAnimalData;
if( delimIndex != -1 )
{
oneAnimalData = s.substr(0, delimIndex);
s = s.substr(delimIndex+1);
}
else
{
oneAnimalData = s;
s = "";
}
ANIMALINFO info;
info.name = oneAnimalData.substr(0, oneAnimalData.find(" ") );
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.key = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.type = (ANIMAL_TYPE)atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.level = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.status.sleep = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.status.poop = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.status.exp = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.status.fullness = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.status.health = atoi(oneAnimalData.substr(0, oneAnimalData.find(" ") ).data());
oneAnimalData = oneAnimalData.substr(oneAnimalData.find(" ")+1);
info.status.joy = atoi(oneAnimalData.data());
CCLog("URL_RECEIVE_ANIMALS : %s %d %d %d %d %d %d %d %d %d", info.name.c_str(), info.key, info.type, info.level, info.status.sleep, info.status.poop, info.status.exp, info.status.fullness, info.status.health, info.status.joy );
pData->makeDataFromAnimalInfo(SceneManager::sharedSceneManager()->getHostAccountKey(), info);
// char name[32] = "께이";
// char strMB[256] = {0,};
// wchar_t strUnicode[256] = {0,};
// memcpy(strUnicode, info.name.data(), info.name.size());
// wcstombs(strMB, info.name.data(), 256);
//
//.........这里部分代码省略.........