get time left Timer Service

0 votes

Hi !

I have a problem, please take a look here http://discuss.cocos2d-x.org/t/converting-date/20612

I'm trying to get the difference between

app42TimerResponse->app42Timer.endTime

app42TimerResponse->app42Timer.startTime

timerService->IsTimerActive(timerName.c_str(), userName.c_str(), app42callback(MainMenu::onTimerServiceRequestCompleted, this,"CHECK"));

void MainMenu::onTimerServiceRequestCompleted( void *response, std::string action)
{
log("//*************************************************//");
log("\nonTimerServiceRequestCompleted... action %s", action.c_str());
App42TimerResponse *app42TimerResponse = (App42TimerResponse*)response;
if(app42TimerResponse->isSuccess)
{
log("\n TimerName =%s",app42TimerResponse->app42Timer.name.c_str());
log("\n timeInSeconds=%ld",app42TimerResponse->app42Timer.timeInSeconds);
log("\n startTime =%s",app42TimerResponse->app42Timer.startTime.c_str());
log("\n endTime =%s",app42TimerResponse->app42Timer.endTime.c_str());
log("\n isTimerActive=%d",app42TimerResponse->app42Timer.isTimerActive);
 
if(action=="CREATE")
{
timeLeft = TIME_PER_ENERGY_S;
timerService->CreateOrUpdateTimer(timerName.c_str(),timeLeft,app42callback(MainMenu::onTimerServiceRequestCompleted, this, "START"));
this->runAction(
Sequence::create(
DelayTime::create(1.5),
CallFuncN::create(CC_CALLBACK_1(MainMenu::reload_friends, this)),
nullptr ));
}
else if(action=="START")
{
timerService->StartTimer(timerName.c_str(),userName.c_str(),app42callback(MainMenu::onTimerServiceRequestCompleted, this, "STARTED"));
//isCounting = true;
}
else if(action=="STARTED")
{
this->runAction(
Sequence::create(
DelayTime::create(1.5),
CallFuncN::create(CC_CALLBACK_1(MainMenu::calculate_time, this,app42TimerResponse->app42Timer.endTime, app42TimerResponse->app42Timer.startTime)),
nullptr ));
}
else if(action=="CHECK")//UPDATES
{
if(app42TimerResponse->app42Timer.isTimerActive)
{
this->runAction(
Sequence::create(
DelayTime::create(1.5),
CallFuncN::create(CC_CALLBACK_1(MainMenu::calculate_time, this,app42TimerResponse->app42Timer.endTime, app42TimerResponse->app42Timer.startTime)),
nullptr ));
}
else
{
timerService->GetCurrentTime(app42callback(MainMenu::onTimerServiceRequestCompleted, this,"CREATE"));
isCounting = false;
}
}
}
else
{
log("\nerrordetails:%s",app42TimerResponse->errorDetails.c_str());
log("\nerrorMessage:%s",app42TimerResponse->errorMessage.c_str());
log("\nappErrorCode:%d",app42TimerResponse->appErrorCode);
log("\nhttpErrorCode:%d",app42TimerResponse->httpErrorCode);
}
 
log("//*************************************************//");
}
 
result:
03-22 10:16:28.102: D/cocos2d-x debug info(19659): //*************************************************//
03-22 10:16:28.102: D/cocos2d-x debug info(19659): onTimerServiceRequestCompleted... action CHECK
03-22 10:16:28.102: D/cocos2d-x debug info(19659):  TimerName =energy_timer
03-22 10:16:28.102: D/cocos2d-x debug info(19659):  timeInSeconds=0
03-22 10:16:28.102: D/cocos2d-x debug info(19659):  startTime =2015-03-22T02:16:17.000Z
03-22 10:16:28.102: D/cocos2d-x debug info(19659):  endTime =2015-03-22T02:17:47.000Z
03-22 10:16:28.102: D/cocos2d-x debug info(19659):  isTimerActive=1
03-22 10:16:28.102: D/cocos2d-x debug info(19659): //*************************************************//
 
asked Mar 22, 2015 in App42PaaS & BPaaS by jvfiel (35 points)
edited Mar 22, 2015 by jvfiel

1 Answer

+1 vote
solved. format problem
answered Mar 22, 2015 by jvfiel (35 points)
Great to hear that your query has been resolved. Let us know if you need further information regarding this.
Thanks,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...