本文整理汇总了C++中CDateTime::getTotalSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ CDateTime::getTotalSeconds方法的具体用法?C++ CDateTime::getTotalSeconds怎么用?C++ CDateTime::getTotalSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDateTime
的用法示例。
在下文中一共展示了CDateTime::getTotalSeconds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
bool C553_Android_Login::init()
{
if( !CCLayer::init() )
return false;
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCSprite *pBackground = CCSprite::create("Loading/loading2_underframe.jpg");
pBackground->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
addChild(pBackground);
const char *_account = CUserCache::sharedUserCache()->getObject("userName");
CCLOG("accountName = %s", _account);
CDateTime nowTime;
int nLocalTime = nowTime.getTotalSeconds();
char szLocalTime[32] = {0};
sprintf(szLocalTime, "%d", nLocalTime);
std::string strSessionId = CCUserDefault::sharedUserDefault()->getStringForKey("sid", "");
const char *lpcszSessionId = strSessionId.c_str();
CDefaultLoginBehavior *pSender = new CDefaultLoginBehavior;
pSender->autorelease();
CLoginHttpApi::setInternalVerify(true);
CLoginHttpApi::httpVerify( CID_w_217, CWebView::urlEncode(_account), CDevice::sharedDevice()->getMAC(), CApplication::sharedApplication()->getBundleVersion(),
"Android", SDK_SOURCE_FROM, SDK_SOURCE_SUB_FROM, szLocalTime,
PRIVATEKEY_W_217, lpcszSessionId, pSender, callfuncND_selector(CDefaultLoginBehavior::defaultHttpVerify) );
return true;
}
示例2: CCMessageBox
void C553_SDK::parseJsonResultData(const char *lpcszJsonData)
{
Json::Value retJson;
Json::Reader jsonReader;
if( jsonReader.parse(lpcszJsonData, retJson))
{
int nRef = retJson["ref"].asInt();
if(nRef == 0)
{
const char *lpcszMessage = retJson["msg"].asCString();
CCMessageBox(lpcszMessage, "Error!");
return;
}
CDateTime nowTime;
int nLocalTime = nowTime.getTotalSeconds();
char szLocalTime[32] = {0};
sprintf(szLocalTime, "%d", nLocalTime);
int nRetTime = retJson["time"].asInt();
int nUuid = retJson["uuid"].asInt(); // 这个要存起来 给别的地方 与 下次 用 by:yiping
const char *lpcszAccount = retJson["account"].asCString();
const char *lpcszSessionId = retJson["session_id"].asCString(); // 这个要存起来 给别的地方 与 下次 用 by:yiping
CCUserDefault::sharedUserDefault()->setStringForKey("sid", lpcszSessionId);
CCUserDefault::sharedUserDefault()->flush();
//mac,account,retTime,cid,version,source,key
char szBuffer[1024];
const char *lpcszMac = CDevice::sharedDevice()->getDeviceIMEI();
const char *lpcszBundleVersion = CApplication::sharedApplication()->getBundleVersion();
sprintf(szBuffer, "%s,%s,%d,%s,%d,%s", lpcszMac, lpcszAccount, nRetTime, CID_w_217, nUuid, PRIVATEKEY_W_217);
const char *lpcszMD5Buffer = CMD5Crypto::md5(szBuffer, strlen(szBuffer));
if( strcmp(retJson["sign"].asCString(), lpcszMD5Buffer) == 0 )
{
if( abs(nLocalTime - nRetTime) <= 600 ) //10分钟
{
//本地服务验证
CCLOG("webview verify successed!");
CLoginHttpApi::httpVerify(CID_w_217, CWebView::urlEncode(lpcszAccount), lpcszMac, lpcszBundleVersion,
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
"iOS"
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
"Android"
#endif
, SDK_SOURCE_FROM, SDK_SOURCE_SUB_FROM, szLocalTime, PRIVATEKEY_W_217,
lpcszSessionId,
this, callfuncND_selector(C553_SDK::onJJAPIResponsed));
//
}
}
else
{
CCMessageBox("sign valid!", "sign code error!");
}
}
else
{
CCMessageBox("json parse error", lpcszJsonData);
}
}
示例3: init
bool CWdj_Login::init()
{
if( !CCLayer::init() )
return false;
CCLOG("CWdj_Login: init");
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCSprite *pBackground = CCSprite::create("Loading/loading2_underframe.jpg");
pBackground->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
addChild(pBackground);
const char *_account = CUserCache::sharedUserCache()->getObject("userName");
CCLOG("accountName = %s", _account);
CDateTime nowTime;
int nLocalTime = nowTime.getTotalSeconds();
char szLocalTime[32] = {0};
sprintf(szLocalTime, "%d", nLocalTime);
std::string strSessionId = CCUserDefault::sharedUserDefault()->getStringForKey("sid", "");
const char *lpcszSessionId = strSessionId.c_str();
CDefaultLoginBehavior *pSender = new CDefaultLoginBehavior;
pSender->autorelease();
CLoginHttpApi::setInternalVerify(true);
CLoginHttpApi::httpVerify( CID_w_217, CWebView::urlEncode(_account), CDevice::sharedDevice()->getMAC(), CApplication::sharedApplication()->getBundleVersion(),
"Android", SDK_SOURCE_FROM, SDK_SOURCE_SUB_FROM, szLocalTime,
PRIVATEKEY_W_217, lpcszSessionId, pSender, callfuncND_selector(CDefaultLoginBehavior::defaultHttpVerify) );
return true;
// if( !CCLayer::init() )
// return false;
//
// CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
// CCSprite *pBackground = CCSprite::create("Loading/loading2_underframe.jpg");
// pBackground->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
// addChild(pBackground);
//
// CCSize portaitDeviceSize = CDevice::sharedDevice()->getScreenSize();
//
// m_pWebView = CWebView::create();
// m_pWebView->setOverrideCallBack(this, (LP_OVERRIDE_WEBVIEW_URL_CALLBACK)(&CMi_Login::shouldOverrideUrl));
//
// m_pWebView->setPreferredSize(CCSizeMake(portaitDeviceSize.width,portaitDeviceSize.height));
//
// char szUrl[1024] = {0};
// getUrl( szUrl, 1024);
// m_pWebView->loadGet(szUrl);
// addChild(m_pWebView);
// return true;
}
示例4: snprintf
void C553_SDK::getUrl(char *lpszUrl, size_t uLength)
{
snprintf(lpszUrl, uLength, SDK_LOGIN_URL, SDK_HOST);
std::string strSessionId = CCUserDefault::sharedUserDefault()->getStringForKey("sid", "");
char szSessionId[1024] = {0};
strcpy(szSessionId, strSessionId.c_str()); // by:yiping
char szParam[1024] = {0};
char szParam2[1024] = {0};
//cid
strcat(szParam, "cid=");
strcat(szParam, CID_w_217);
//mac
strcat(szParam, "&mac=");
strcat(szParam, CDevice::sharedDevice()->getDeviceIMEI());
//versions
strcat(szParam, "&versions=");
strcat(szParam, CApplication::sharedApplication()->getBundleVersion());
//os
strcat(szParam, "&os=");
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
strcat(szParam, "iOS");
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
strcat(szParam, "Android");
#endif
//source
strcat(szParam, "&source=");
strcat(szParam, SDK_SOURCE_FROM);
//source_sub
strcat(szParam, "&source_sub=");
strcat(szParam, SDK_SOURCE_SUB_FROM);
//time
strcat(szParam, "&time=");
CDateTime nowTime;
char szTimeStr[32] = {0};
sprintf(szTimeStr, "%d", nowTime.getTotalSeconds() );
strcat(szParam, szTimeStr );
strcpy(szParam2, szParam);
//key
strcat(szParam, "&key=");
strcat(szParam, PRIVATEKEY_W_217);
std::string strSign = CMD5Crypto::md5(szParam, strlen(szParam));
strcat(szParam2, "&sign=");
strcat(szParam2, strSign.c_str());
strcat(szParam2, "&session=");
strcat(szParam2, szSessionId);
strcat( lpszUrl, "?" );
strcat( lpszUrl, szParam2);
}