本文整理汇总了C++中NetConnection::isPending方法的典型用法代码示例。如果您正苦于以下问题:C++ NetConnection::isPending方法的具体用法?C++ NetConnection::isPending怎么用?C++ NetConnection::isPending使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetConnection
的用法示例。
在下文中一共展示了NetConnection::isPending方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleWSResponseData
/*
* 处理 web 服务器响应 get 请求回应数据
*/
void LoginLayer::handleWSResponseData(const char *szData, const unsigned int dataSize, char* szTag) {
CCAssert(szData && dataSize > 0 && szTag, "invalid data");
bool isSuccess = false;
if (!strcmp(szTag, HTTP_REQUEST_LOGIN_TAG)) /*登录请求*/ {
isSuccess = ProcessData::processLoginResponseFromServer(szData, dataSize);
if (isSuccess) {
// 登陆成功,请求玩家武将信息
NetConnection* pNetConnection = NetConnection::getInstance();
char szPostBuffer[MAX_POSTTO_SERVER_BUFFER_SIZE];
memset(szPostBuffer, '\0', MAX_POSTTO_SERVER_BUFFER_SIZE);
sprintf(szPostBuffer, "c=hero&a=hero_list&uid=%s", GamePlayer::getInstance()->getUid().c_str());
char szTag[] = HTTP_REQUEST_GETHERO_TAG;
pNetConnection->commitPostRequestData(szPostBuffer, szTag);
}
} else if (!strcmp(szTag, HTTP_REQUEST_GETHERO_TAG)) /*武将数据*/ {
NetConnection* pNetConnection = NetConnection::getInstance();
do {
CC_BREAK_IF(!ProcessData::processHerosDataFromServer(szData, dataSize));
// 还有 “未决” 请求
CC_BREAK_IF(pNetConnection->isPending());
// 武将管理
HeroManager* pHeroManager = HeroManager::getInstance();
// 恢复战队位置
pHeroManager->restoreBattleTeamPosIndex();
if (m_pGameState->hasEndlessFight()) /* 有未完成战斗 */ {
Battle* pBattle = Battle::getInstance();
// 恢复副本id
m_pGameState->setCopyId(m_pGameState->getEndlessFightCopyId());
// 恢复关卡id
m_pGameState->setLevId(m_pGameState->getEndlessFightLevelId());
// 恢复战斗波数
pBattle->setRoundIndex(m_pGameState->getEndlessFightRoundIndex() - 1);
// 往战场添加本方上阵武将
unsigned int countOfGotoBattleHeros = pHeroManager->getGoIntoBattleHerosOfPlayerCount();
for (unsigned int index = 0; index < countOfGotoBattleHeros; index++) {
HeroOfPlayerItem* pGotoBattleHeroItem = pHeroManager->getGoIntoBattleHeroDataByIndex(index);
CCAssert(pGotoBattleHeroItem, "invalid data");
unsigned int posIndexInBattle = m_pGameState->getUfTeamPos(pGotoBattleHeroItem->getUniId());
CCAssert(posIndexInBattle > 0, "invalid posIndexInBattle");
pGotoBattleHeroItem->setPosInBattle(posIndexInBattle);
pBattle->appendInBattleHero(pGotoBattleHeroItem);
} /*for*/
pHeroManager->saveBattleTeamPosIndex();
// 提交战斗请求
pBattle->commitPveFightRequest();
} else {
pNetConnection->setHandleNetDataDelegate(NULL);
/* 设置login调用了主场景 */
m_pGameState->setTagWhoCallMainScene(1);
CCDirector::sharedDirector()->replaceScene(MainScene::create());
CCNotificationCenter::sharedNotificationCenter()->postNotification(ON_MESSAGE_SHUTDOWN_LOADING);
}
} while (0);
} else if (!strcmp(szTag, HTTP_REQUEST_FIGHT_PVE_TAG)) /*战斗请求*/{
NetConnection* pNetConnection = NetConnection::getInstance();
bool isSuccess = ProcessData::parseBufferFromSvr(szData, dataSize, szTag);
if (isSuccess) {
pNetConnection->setHandleNetDataDelegate(NULL);
CCDirector::sharedDirector()->replaceScene(BattleScene::create());
}
}
}