Timer Service

Timer Service facilitates developers to create and maintain server side timer in their app/game. APIs create and maintain the status of the timer on App42 Cloud so that developers don’t have to maintain it on the client side. Developers don’t have to write any business logic, the timer just needs to be configured. Using this service one can create, delete, start, stop and check the status of the timer. Sample use case: timers in strategy games.

Import Statement
  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
import com.shephertz.app42.paas.sdk.android.App42API;
import com.shephertz.app42.paas.sdk.android.App42Exception;
import com.shephertz.app42.paas.sdk.android.App42Response;
import com.shephertz.app42.paas.sdk.android.App42BadParameterException;
import com.shephertz.app42.paas.sdk.android.App42NotFoundException;
import com.shephertz.app42.paas.sdk.android.timer.Timer;
import com.shephertz.app42.paas.sdk.android.timer.TimerService;
Not Available
#import "Shephertz_App42_iOS_API/Shephertz_App42_iOS_API.h"
import "Shephertz_App42_iOS_API/Shephertz_App42_iOS_API.h"
import com.shephertz.app42.paas.sdk.java.App42API;
import com.shephertz.app42.paas.sdk.java.App42Response;
import com.shephertz.app42.paas.sdk.java.App42Exception;
import com.shephertz.app42.paas.sdk.java.App42BadParameterException;
import com.shephertz.app42.paas.sdk.java.App42NotFoundException;
import com.shephertz.app42.paas.sdk.java.timer.Timer;
import com.shephertz.app42.paas.sdk.java.timer.TimerService;
using com.shephertz.app42.paas.sdk.csharp;  
using com.shephertz.app42.paas.sdk.csharp.timer;  
<script type="text/javascript" src="App42-all-x.x.x.min.js"></script>
local App42API = require("App42-Lua-API.App42API")
#include "App42API.h"
Not Available
include_once '../TimerService.php'; 
include_once '../App42Response.php';  
include_once '../App42Exception.php';   
include_once '../App42BadParameterException.php';  
include_once '../App42NotFoundException.php'; 
include_once '../App42Log.php';
Not Available
Not Available
import com.shephertz.app42.paas.sdk.as3.App42CallBack;
import com.shephertz.app42.paas.sdk.as3.App42Exception;
import com.shephertz.app42.paas.sdk.as3.App42API;
import com.shephertz.app42.paas.sdk.as3.timer.Timer;
import com.shephertz.app42.paas.sdk.as3.timer.TimerService;
Not Available
Not Available
Initialize

In order to use the various functions available in a specific API, the developer has to initialize with App42API by passing the apiKey and the secretKey which will become available after the app creation from AppHQ dashboard.

Required Parameters

apiKey - The Application key given when the application was created. secretKey - The secret key corresponding to the application key given when the application was created.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
App42API.Initialize("API_KEY","SECRET_KEY");
[App42API initializeWithAPIKey:@"APP_KEY" andSecretKey:@"SECRET_KEY"]; 
App42API.initializeWithAPIKey("API_KEY", andSecretKey:"SECRET_KEY")        
App42API.initialize("API_KEY","SECRET_KEY");
App42API.Initialize("API_KEY","SECRET_KEY");
App42.initialize("API_KEY","SECRET_KEY");
App42API:initialize("API_KEY","SECRET_KEY");
App42API::Initialize("API_KEY", "SECRET_KEY");
App42API.Initialize("API_KEY","SECRET_KEY");
App42API::initialize("API_KEY","SECRET_KEY"); 
App42API::Initialize("API_KEY", "SECRET_KEY");
api = App42::ServiceAPI.new("API_KEY","SECRET_KEY")   
App42API.initialize("API_KEY","SECRET_KEY");
Coming Soon
App42API.initialize("API_KEY","SECRET_KEY");
Build Service

After initialization, the developer will have to call the buildXXXService method on App42API to get the instance of the particular API that they wish to build. For example, to build an instance of TimerService, buildTimerService() method needs to be called.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
TimerService timerService = App42API.buildTimerService(); 
Coming Soon 
TimerService *timerService = [App42API buildTimerService];
let timerService = App42API.buildTimerService() as? TimerService
TimerService timerService =  App42API.buildTimerService(); 
TimerService timerService =  App42API.BuildTimerService(); 
var timerService  = new App42Timer();
local timerService  = App42API:buildTimerService()
TimerService *timerService = App42API::BuildTimerService();
Coming Soon 
$timerService = App42API::buildTimerService(); 
Coming Soon
Coming Soon 
var timerService:TimerService = App42API.buildTimerService(); 
Coming Soon
Coming Soon
Create Or Update Timer

Create a new timer and also update the time of existing timer.

Required Parameters

timerName - Name of the timer which has to be created. timeInSeconds - Times in seconds upto which timer will remain active.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String timerName = "<Enter_your_timer_name>";
long timeInSeconds= 120;
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
TimerService timerService = App42API.buildTimerService();
timerService.createOrUpdateTimer(timerName, timeInSeconds, new App42CallBack() {
public void onSuccess(Object response) 
{
	Timer timer = (Timer)response;      
	System.out.println("Timer Name is: "+timer.getName());
	System.out.println("Time is: "+timer.getTimeInSeconds());
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
Not Available
NSString *timerName = @"<Enter_your_timer_name>";
long timerInSeconds = 120;
[App42API initializeWithAPIKey:"APP_KEY" andSecretKey:"SECRET_KEY"];
TimerService *timerService = [App42API buildTimerService];
[timerService createOrUpdateTimerWithName:timerName timeInSeconds:timerInSeconds completionBlock:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		Timer *timer = (Timer*)responseObj;		
		NSLog(@"TimerName = %@",timer.name);
		NSLog(@"TimeInSeconds = %ld",timer.timeInSeconds);
	}
	else
	{
		NSLog(@"Exception = %@",[exception reason]);
		NSLog(@"HTTP error Code = %d",[exception httpErrorCode]);
		NSLog(@"App Error Code = %d",[exception appErrorCode]);
		NSLog(@"User Info = %@",[exception userInfo]);
	}
}];
let timerName = "<Enter_your_timer_name>"
let timerInSeconds = 120
App42API.initializeWithAPIKey("API_KEY", andSecretKey: "SECRET_KEY")
let timerService = App42API.buildTimerService() as! TimerService()
timerService?.createOrUpdateTimerWithName(timerName, timeInSeconds:timerInSeconds, completionBlock:{ (success, response, exception) -> Void in
    if (success)
    {
        let timer = response as! Timer
        NSLog("TimerName = %@",timer.name)
        NSLog("TimeInSeconds = %ld",timer.timeInSeconds)
    }
    else
    {
        NSLog("%@", exception.reason!)
        NSLog("%d", exception.appErrorCode)
        NSLog("%d", exception.httpErrorCode)
    }  
})
String timerName = "<Enter_your_timer_name>";
long timeInSeconds= 120;
App42API.initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.buildTimerService(); 
Timer timer = timerService.createOrUpdateTimer(timerName, timeInSeconds);
System.out.println("Timer Name is: "+timer.getName());
System.out.println("Time is: "+timer.getTimeInSeconds());
String timerName = "<Enter_your_timer_name>";
long timeInSeconds= 120;
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.BuildTimerService();
timerService.CreateOrUpdateTimer(timerName, timeInSeconds, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Timer timer = (Timer)response;
		App42Log.Console("Timer Name is: "+timer.GetName());
		App42Log.Console("Time is: "+timer.GetTimeInSeconds());
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
var timerName = "<Enter_your_timer_name>",timeInSeconds= 120;
var result;
App42.initialize("API_KEY","SECRET_KEY");
var timerService  = new App42Timer();
timerService.createOrUpdateTimer(timerName, timeInSeconds ,{
success: function(object) 
{
	var timerObj = JSON.parse(object);
	result = timerObj.app42.response.timer;
	console.log("Timer Name is: "+result.name);
	console.log("Time is: "+result.timeInSeconds);
},
error: function(error) {
}
});
local timerName = "<Enter_your_timer_name>";
local timeInSeconds= 120;
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local timerService  = App42API:buildTimerService()
timerService:createOrUpdateTimer(timerName,timeInSeconds,App42CallBack)
function App42CallBack:onSuccess(object)
	print("Timer name is:"..object:getName());
	print("Time"..object:getTimeInSeconds());
end 
function App42CallBack:onException(exception)
	print("Message is : "..exception:getMessage())
	print("App Error code is : "..exception:getAppErrorCode())
	print("Http Error code is "..exception:getHttpErrorCode())
	print("Detail is : "..exception:getDetails())
end 
const char* timerName = "<Enter_your_timer_name>";
long timeInSeconds = 1000;
App42API::Initialize("API_KEY", "SECRET_KEY");
TimerService *timerService = App42API::BuildTimerService();
timerService->CreateOrUpdateTimer(timerName,timeInSeconds,app42callback(Sample_Class::onTimerServiceRequestCompleted, this));

void Sample_Class::onTimerServiceRequestCompleted( void *response)
{
    App42TimerResponse *app42TimerResponse = (App42TimerResponse*)response;
    if(app42TimerResponse->isSuccess)
    {
        printf("\ncode=%d",app42TimerResponse->getCode());
        printf("\nisSuccess=%d",app42TimerResponse->isSuccess);
        printf("\nResponse Body=%s",app42TimerResponse->getBody().c_str());
        printf("\n TimerName =%s",app42TimerResponse->app42Timer.name.c_str());
        printf("\n timeInSeconds=%ld",app42TimerResponse->app42Timer.timeInSeconds);
    }
    else
    {
        printf("\nerrordetails:%s",app42TimerResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",app42TimerResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",app42TimerResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",app42TimerResponse->httpErrorCode);
    }
}

Not Available
$timerName = "<Enter_your_timer_name>";
$timeInSeconds= 120;   
App42API::initialize("API_KEY","SECRET_KEY"); 
$timerService = App42API::buildTimerService(); 
$timer = $timerService->createOrUpdateTimer($timerName, $timeInSeconds);
print_r("Timer Name is: ".$timer->getName());
print_r("Timer Name is: ".$timer->getTimeInSeconds());  
Not Available
Not Available
var timerName:String = "<Enter_your_timer_name>";
var timeInSeconds:int= 120;
App42API.initialize("API_KEY","SECRET_KEY");
var timerService:TimerService = App42API.buildTimerService(); 
timerService.createOrUpdateTimer(timerName,timeInSeconds ,new callback());
class callback implements App42CallBack
{
	public function onSuccess(response:Object):void
	{
		var timer:Timer = Timer(response);
		trace(" Name  is :  "+timer.getName());
		trace("Time :" +timer.getTimeInSeconds());
	}
	public function onException(exception:App42Exception):void
	{
		trace("Exception Message " + exception);  
	}
}
Not Available
Not Available
Start Timer

Start the timer count down for a particular user.

Required Parameters

timerName - Name of the timer which has to be started. userName - Name of the user whose timer count down has to be started.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
TimerService timerService = App42API.buildTimerService();
timerService.startTimer(timerName, userName, new App42CallBack() {
public void onSuccess(Object response) 
{
	Timer timer = (Timer)response;      
	System.out.println("Current time is:" + timer.getCurrentTime());
	System.out.println("Timer name is:" + timer.getName());
	System.out.println("Start time is:" + timer.getStartTime());
	System.out.println("End time is:" + timer.getEndTime());
	System.out.println("UserName is:" + timer.getUserName());
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
Not Available
NSString *timerName = @"<Enter_your_timer_name>";
NSString *userName = @"John";
[App42API initializeWithAPIKey:"APP_KEY" andSecretKey:"SECRET_KEY"];
TimerService *timerService = [App42API buildTimerService];
[timerService startTimerWithName:timerName forUser:userName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		Timer *timer = (Timer*)responseObj;		
		NSLog(@"TimerName = %@",timer.name);
		NSLog(@"CurrentTime = %@",timer.currentTime);
		NSLog(@"StartTime = %@",timer.startTime);
		NSLog(@"EndTime = %@",timer.endTime);
		NSLog(@"UserName = %@",timer.userName);
	}
	else
	{
		NSLog(@"Exception = %@",[exception reason]);
		NSLog(@"HTTP error Code = %d",[exception httpErrorCode]);
		NSLog(@"App Error Code = %d",[exception appErrorCode]);
		NSLog(@"User Info = %@",[exception userInfo]);
	}
}];
let timerName = "<Enter_your_timer_name>"
let userName = "John"
App42API.initializeWithAPIKey("API_KEY", andSecretKey: "SECRET_KEY")
let timerService = App42API.buildTimerService() as! TimerService()
timerService?.startTimerWithName(timerName, forUser:userName, completionBlock:{ (success, response, exception) -> Void in
    if (success)
    {
        let timer = response as! Timer
        NSLog("TimerName = %@",timer.name);
        NSLog("CurrentTime = %@",timer.currentTime);
        NSLog("StartTime = %@",timer.startTime);
        NSLog("EndTime = %@",timer.endTime);
        NSLog("UserName = %@",timer.userName);
    }
    else
    {
        NSLog("%@", exception.reason!)
        NSLog("%d", exception.appErrorCode)
        NSLog("%d", exception.httpErrorCode)
        NSLog("%@", exception.userInfo!)  
    }  
})
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42API.initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.buildTimerService(); 
Timer timer = timerService.startTimer(timerName, userName);
System.out.println("Current time is:" + timer.getCurrentTime());
System.out.println("Timer name is:" + timer.getName());
System.out.println("Start time is:" + timer.getStartTime());
System.out.println("End time is:" + timer.getEndTime());
System.out.println("UserName is:" + timer.getUserName());
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.BuildTimerService();
timerService.StartTimer(timerName, userName, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Timer timer = (Timer)response;
		App42Log.Console("Timer Name is: "+timer.GetName());
		App42Log.Console("UserName is:" + timer.GetUserName());
		App42Log.Console("Current time is:" + timer.GetCurrentTime());
		App42Log.Console("Start time is:" + timer.GetStartTime());
		App42Log.Console("End time is:" + timer.GetEndTime());
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
var timerName = "<Enter_your_timer_name>" , 
userName= "John" , 
result;
App42.initialize("API_KEY","SECRET_KEY");
var timerService  = new App42Timer();
timerService.startTimer(timerName, userName,{
	success: function(object) 
	{
		var timerObj = JSON.parse(object);
		result = timerObj.app42.response.timer;
		console.log("Timer name is:" +result.name);
		console.log("Current time is:" + result.currentTime);
		console.log("End time is:" + result.endTime);
		console.log("Start time is:" + result.startTime);
		console.log("UserName is:" + result.userName);	
	},
	error: function(error) {
	}
});
local timerName = "<Enter_your_timer_name>";
local userName= "John";
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local timerService  = App42API:buildTimerService()
timerService:startTimer(timerName,userName,App42CallBack)
function App42CallBack:onSuccess(object)
	print("Current time is:" .. object:getCurrentTime());
	print("Timer name is:"..object:getName());
	print("Start time is:"..object:getStartTime());
	print("End time is:" ..object:getEndTime());
	print("UserName is:" ..object:getUserName());
end  
function App42CallBack:onException(exception)
	print("Message is : "..exception:getMessage())
	print("App Error code is : "..exception:getAppErrorCode())
	print("Http Error code is "..exception:getHttpErrorCode())
	print("Detail is : "..exception:getDetails())
end
const char* timerName = "<Enter_your_timer_name>";
const char* userName = "John";
App42API::Initialize("API_KEY", "SECRET_KEY");
TimerService *timerService = App42API::BuildTimerService();
timerService->StartTimer(timerName,userName,app42callback(Sample_Class::onTimerServiceRequestCompleted, this));

void Sample_Class::onTimerServiceRequestCompleted( void *response)
{
    App42TimerResponse *app42TimerResponse = (App42TimerResponse*)response;
    if(app42TimerResponse->isSuccess)
    {
        printf("\ncode=%d",app42TimerResponse->getCode());
        printf("\nisSuccess=%d",app42TimerResponse->isSuccess);
        printf("\nResponse Body=%s",app42TimerResponse->getBody().c_str());
        printf("\n TimerName =%s",app42TimerResponse->app42Timer.name.c_str());
        printf("\n userName =%s",app42TimerResponse->app42Timer.userName.c_str());
        printf("\n currentTime =%s",app42TimerResponse->app42Timer.currentTime.c_str());
        printf("\n startTime =%s",app42TimerResponse->app42Timer.startTime.c_str());
        printf("\n endTime =%s",app42TimerResponse->app42Timer.endTime.c_str());
        printf("\n isTimerActive=%d",app42TimerResponse->app42Timer.isTimerActive);
    }
    else
    {
        printf("\nerrordetails:%s",app42TimerResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",app42TimerResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",app42TimerResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",app42TimerResponse->httpErrorCode);
    }
}

Not Available
$timerName = "<Enter_your_timer_name>";
$userName= "John";
App42API::initialize("API_KEY","SECRET_KEY"); 
$timerService = App42API::buildTimerService(); 
$timer = $timerService->startTimer($timerName, $userName);
print_r("Current time is:" .$timer->getCurrentTime());
print_r("Timer name is:" .$timer->getName());
print_r("Start time is:" .$timer->getStartTime());
print_r("End time is:" .$timer->getEndTime());
print_r("UserName is:" .$timer->getUserName());
Not Available
Not Available
var timerName:String = "<Enter_your_timer_name>";
var userName:String= "John";
App42API.initialize("API_KEY","SECRET_KEY");
var timerService:TimerService = App42API.buildTimerService(); 
timerService.startTimer(timerName,userName,new callback());
class callback implements App42CallBack{
	public function onSuccess(response:Object):void
	{
		var timer:Timer = Timer(response);
		trace("Timer Name is :  "+timer.getName());
		trace("User name :" +timer.getUserName());		
		trace("Current Time :" +timer.getCurrentTime());	
		trace("Start Time :" +timer.getStartTime());			
		trace("End Time :" +timer.getEndTime());
	}
	public function onException(exception:App42Exception):void
	{
		trace("Exception Message " + exception);  
	}
}
Not Available
Not Available
Active Status of Timer

Check the status of timer whether it is active or not.

Required Parameters

timerName - Name of the timer which has to be checked. userName - Name of the user for whom you want check the status of timer.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
TimerService timerService = App42API.buildTimerService();
timerService.isTimerActive(timerName, userName, new App42CallBack() {
public void onSuccess(Object response) 
{
	Timer timer = (Timer)response;      
	System.out.println("Timer name is:" + timer.getName());
	System.out.println("Start time is:" + timer.getStartTime());
	System.out.println("End time is:" + timer.getEndTime());
	System.out.println("UserName is:" + timer.getUserName());
	System.out.println("Is timer active :" + timer.getIsTimerActive());
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
Not Available
NSString *timerName = @"<Enter_your_timer_name>";
NSString *userName = @"John";
[App42API initializeWithAPIKey:"APP_KEY" andSecretKey:"SECRET_KEY"];
TimerService *timerService = [App42API buildTimerService];
[timerService isTimerActive:timerName forUser:userName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		Timer *timer = (Timer*)responseObj;		
		NSLog(@"TimerName = %@",timer.name);
		NSLog(@"StartTime = %@",timer.startTime);
		NSLog(@"EndTime = %@",timer.endTime);
		NSLog(@"IsTimerActive = %d",timer.isTimerActive);
	}
	else
	{
		NSLog(@"Exception = %@",[exception reason]);
		NSLog(@"HTTP error Code = %d",[exception httpErrorCode]);
		NSLog(@"App Error Code = %d",[exception appErrorCode]);
		NSLog(@"User Info = %@",[exception userInfo]);
	}
}];
let timerName = "<Enter_your_timer_name>" 
let userName = "John" 
App42API.initializeWithAPIKey("API_KEY", andSecretKey: "SECRET_KEY") 
let timerService = App42API.buildTimerService() as! TimerService()  
timerService?.isTimerActive(timerName, forUser:userName, completionBlock:{ (success, response, exception) -> Void in
    if (success)
    {
        let timer = response as! Timer
        NSLog("TimerName = %@",timer.name);
        NSLog("IsTimerActive = %d",timer.isTimerActive);
        NSLog("User Name = %@",timer.userName);
    }
    else
    {
        NSLog("%@", exception.reason!)
        NSLog("%d", exception.appErrorCode)
        NSLog("%d", exception.httpErrorCode)
    }  
})
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42API.initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.buildTimerService(); 
Timer timer = timerService.isTimerActive(timerName, userName);
System.out.println("Timer name is:" + timer.getName());
System.out.println("Start time is:" + timer.getStartTime());
System.out.println("End time is:" + timer.getEndTime());
System.out.println("UserName is:" + timer.getUserName());
System.out.println("Is timer active :" + timer.getIsTimerActive());
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.BuildTimerService();
timerService.IsTimerActive(timerName, userName, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Timer timer = (Timer)response;
		App42Log.Console("Timer Name is: "+timer.GetName());
		App42Log.Console("UserName is:" + timer.GetUserName());
		App42Log.Console("Is timer active :" + timer.GetIsTimerActive());
		App42Log.Console("Start time is:" + timer.GetStartTime());
		App42Log.Console("End time is:" + timer.GetEndTime());
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
var timerName = "<Enter_your_timer_name>";
, userName= "John", result;
App42.initialize("API_KEY","SECRET_KEY");
var timerService  = new App42Timer();
timerService.isTimerActive(timerName, userName,{
	success: function(object) 
	{
		var timerObj = JSON.parse(object);
		result=timerObj.app42.response.timer;
		console.log("Timer name is:" +result.name);
		console.log("End time is:" + result.endTime);
		console.log("Is timer active :" +result.isTimerActive);
		console.log("Start time is:" +result.startTime);
		console.log("UserName is:" +result.userName);
	},
	error: function(error) {
	}
});
local timerName = "<Enter_your_timer_name>";
local userName= "John";
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local timerService  = App42API:buildTimerService()
timerService:isTimerActive(timerName,userName,App42CallBack)
function App42CallBack:onSuccess(object)
	print(object:getIsTimerActive());
	print("Timer name is:"..object:getName());
	print("Start time is:"..object:getStartTime());
	print("End time is:" ..object:getEndTime());
	print("UserName is:" ..object:getUserName());
end  
function App42CallBack:onException(exception)
	print("Message is : "..exception:getMessage())
	print("App Error code is : "..exception:getAppErrorCode())
	print("Http Error code is "..exception:getHttpErrorCode())
	print("Detail is : "..exception:getDetails())
end
const char* timerName = "<Enter_your_timer_name>";
const char* userName = "John";
App42API::Initialize("API_KEY", "SECRET_KEY");
TimerService *timerService = App42API::BuildTimerService();
timerService->IsTimerActive(timerName, userName, app42callback(Sample_Class::onTimerServiceRequestCompleted, this));
void Sample_Class::onTimerServiceRequestCompleted( void *response)
{
    App42TimerResponse *app42TimerResponse = (App42TimerResponse*)response;
    if(app42TimerResponse->isSuccess)
    {
        printf("\ncode=%d",app42TimerResponse->getCode());
        printf("\nisSuccess=%d",app42TimerResponse->isSuccess);
        printf("\nResponse Body=%s",app42TimerResponse->getBody().c_str());
        printf("\n TimerName =%s",app42TimerResponse->app42Timer.name.c_str());
        printf("\n userName =%s",app42TimerResponse->app42Timer.userName.c_str());
        printf("\n startTime =%s",app42TimerResponse->app42Timer.startTime.c_str());
        printf("\n endTime =%s",app42TimerResponse->app42Timer.endTime.c_str());
        printf("\n isTimerActive=%d",app42TimerResponse->app42Timer.isTimerActive);
    }
    else
    {
        printf("\nerrordetails:%s",app42TimerResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",app42TimerResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",app42TimerResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",app42TimerResponse->httpErrorCode);
    }
}
Not Available
$timerName = "<Enter_your_timer_name>";
$userName= "John";
App42API::initialize("API_KEY","SECRET_KEY"); 
$timerService = App42API::buildTimerService(); 
$time = $timerService->isTimerActive($timerName, $userName);
print_r("Timer name is:" .$timer->getName());
print_r("Start time is:" .$timer->getStartTime());
print_r("End time is:" .$timer->getEndTime());
print_r("UserName is:" .$timer->getUserName());
print_r("Is timer active :".$timer->getIsTimerActive());
Not Available
Not Available
var timerName:String = "<Enter_your_timer_name>";
var userName:String= "John";
App42API.initialize("API_KEY","SECRET_KEY");
var timerService:TimerService = App42API.buildTimerService(); 
timerService.isTimerActive(timerName,userName,new callback());
class callback implements App42CallBack{
	public function onSuccess(response:Object):void
	{
		var timer:Timer = Timer(response);
		trace("Timer Name is :  "+timer.getName());
		trace("User name :" +timer.getUserName());	
		trace("Start Time :" +timer.getStartTime());			
		trace("End Time :" +timer.getEndTime());
		trace("Is Timer Active :" + timer.getIsTimerActive());
	}
	public function onException(exception:App42Exception):void
	{
		trace("Exception Message " + exception);  
	}
}
Not Available
Not Available
Cancel Timer

Cancel the timer count down for a particular user.

Required Parameters

timerName - Name of the timer which has to be cancelled. userName - Name of the user for whom you want to cancel the timer count down.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
TimerService timerService = App42API.buildTimerService();
timerService.cancelTimer(timerName, userName, new App42CallBack() {
public void onSuccess(Object response) 
{
	Timer timer = (Timer)response;      
	System.out.println("Timer name is:" + timer.getName());
	System.out.println("UserName is:" + timer.getUserName());
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
Not Available
NSString *timerName = @"<Enter_your_timer_name>";
NSString *userName = @"John";
[App42API initializeWithAPIKey:"APP_KEY" andSecretKey:"SECRET_KEY"];
TimerService *timerService = [App42API buildTimerService];
[timerService cancelTimerWithName:timerName forUser:userName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		Timer *timer = (Timer*)responseObj;		
		NSLog(@"TimerName = %@",timer.name);
		NSLog(@"UserName = %@",timer.userName);
	}
	else
	{
		NSLog(@"Exception = %@",[exception reason]);
		NSLog(@"HTTP error Code = %d",[exception httpErrorCode]);
		NSLog(@"App Error Code = %d",[exception appErrorCode]);
		NSLog(@"User Info = %@",[exception userInfo]);
	}
}];
let timerName = "<Enter_your_timer_name>" 
let userName = "John" 
App42API.initializeWithAPIKey("API_KEY", andSecretKey: "SECRET_KEY") 
let timerService = App42API.buildTimerService() as! TimerService()  
timerService?.cancelTimerWithName(timerName, forUser:userName, completionBlock:{ (success, response, exception) -> Void in
    if (success)
    {
        let timer = response as! Timer
        NSLog("TimerName = %@",timer.name)
        NSLog("UserName = %@",timer.userName)
    }
    else
    {
        NSLog("%@", exception.reason!)
        NSLog("%d", exception.appErrorCode)
        NSLog("%d", exception.httpErrorCode)
        NSLog("%@", exception.userInfo!)  
    }  
})
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42API.initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.buildTimerService(); 
Timer timer = timerService.cancelTimer(timerName, userName);
System.out.println("Timer name is:" + timer.getName());
System.out.println("UserName is:" + timer.getUserName());
String timerName = "<Enter_your_timer_name>";
String userName= "John";
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.BuildTimerService();
timerService.CancelTimer(timerName, userName, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Timer timer = (Timer)response;
		App42Log.Console("Timer Name is: "+timer.GetName());
		App42Log.Console("UserName is:" + timer.GetUserName());
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
var timerName = "<Enter_your_timer_name>";
, userName= "John" , result;
App42.initialize("API_KEY","SECRET_KEY");
var timerService  = new App42Timer();
timerService.cancelTimer(timerName, userName,{
success: function(object) 
{
	var timerObj = JSON.parse(object);
	result = timerObj.app42.response.timer;
	console.log("Timer name is:" + result.name);
	console.log("UserName is:" + result.userName);
},
error: function(error) {
}
});
local timerName = "<Enter_your_timer_name>";
local userName= "John";
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local timerService  = App42API:buildTimerService()
timerService:cancelTimer(timerName,userName,App42CallBack)
function App42CallBack:onSuccess(object)
	print("Timer name is:"..object:getName());
	print("UserName is:" ..object:getUserName());
end  
function App42CallBack:onException(exception)
	print("Message is : "..exception:getMessage())
	print("App Error code is : "..exception:getAppErrorCode())
	print("Http Error code is "..exception:getHttpErrorCode())
	print("Detail is : "..exception:getDetails())
end
const char* timerName = "<Enter_your_timer_name>";
const char* userName = "John";
App42API::Initialize("API_KEY", "SECRET_KEY");
TimerService *timerService = App42API::BuildTimerService();
timerService->CancelTimer(timerName, userName, app42callback(Sample_Class::onTimerServiceRequestCompleted, this));

void Sample_Class::onTimerServiceRequestCompleted( void *response)
{
    App42TimerResponse *app42TimerResponse = (App42TimerResponse*)response;
    if(app42TimerResponse->isSuccess)
    {
        printf("\ncode=%d",app42TimerResponse->getCode());
        printf("\nisSuccess=%d",app42TimerResponse->isSuccess);
        printf("\nResponse Body=%s",app42TimerResponse->getBody().c_str());
        printf("\n TimerName =%s",app42TimerResponse->app42Timer.name.c_str());
        printf("\n userName =%s",app42TimerResponse->app42Timer.userName.c_str());
    }
    else
    {
        printf("\nerrordetails:%s",app42TimerResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",app42TimerResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",app42TimerResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",app42TimerResponse->httpErrorCode);
    }
}
Not Available
$timerName = "<Enter_your_timer_name>";
$userName= "John";
App42API::initialize("API_KEY","SECRET_KEY"); 
$timerService = App42API::buildTimerService(); 
$timer = $timerService->cancelTimer($timerName, $userName);
print_r("Timer name is:" .$timer->getName());
print_r("UserName is:" .$timer->getUserName());
Not Available
Not Available
var timerName:String = "<Enter_your_timer_name>";
var userName:String= "John";
App42API.initialize("API_KEY","SECRET_KEY");
var timerService:TimerService = App42API.buildTimerService(); 
timerService.cancelTimer(timerName,userName,new callback());
class callback implements App42CallBack{
	public function onSuccess(response:Object):void
	{
		var timer:Timer = Timer(response);
		trace("Timer Name is :  "+timer.getName());
		trace("User name :" +timer.getUserName());
	}
	public function onException(exception:App42Exception):void
	{
		trace("Exception Message " + exception);  
	}
}
Not Available
Not Available
Delete Timer

Delete a timer based on timer name.

Required Parameters

timerName - Name of the timer which has to be deleted.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String timerName = "<Enter_your_timer_name>";
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
TimerService timerService = App42API.buildTimerService();
timerService.deleteTimer(timerName, new App42CallBack() {
public void onSuccess(Object response) 
{
	App42Response app42response = (App42Response)response;      
	System.out.println("response is " + app42response) ;  
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
Not Available
NSString *timerName = @"<Enter_your_timer_name>";
[App42API initializeWithAPIKey:"APP_KEY" andSecretKey:"SECRET_KEY"];
TimerService *timerService = [App42API buildTimerService];
[timerService deleteTimerWithName:timerName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		App42Response *app42Response = (App42Response*)responseObj;	
		NSLog(@"isSuccess = %d",app42Response.isResponseSuccess);
		NSLog(@"Response=%@",app42Response.strResponse);
	}
	else
	{
		NSLog(@"Exception = %@",[exception reason]);
		NSLog(@"HTTP error Code = %d",[exception httpErrorCode]);
		NSLog(@"App Error Code = %d",[exception appErrorCode]);
		NSLog(@"User Info = %@",[exception userInfo]);
	}
}];
let timerName = "<Enter_your_timer_name>" 
App42API.initializeWithAPIKey("API_KEY", andSecretKey: "SECRET_KEY") 
let timerService = App42API.buildTimerService() as! TimerService() 
timerService?.deleteTimerWithName(timerName, completionBlock:{ (success, response, exception) -> Void in
    if (success)
    {
        let app42Response = response as! App42Response
        NSLog("%@", app42Response.strResponse)
    }
    else
    {
        NSLog("%@", exception.reason!)
        NSLog("%d", exception.appErrorCode)
        NSLog("%d", exception.httpErrorCode)
        NSLog("%@", exception.userInfo!)  
    }  
})
String timerName = "<Enter_your_timer_name>";
App42API.initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.buildTimerService(); 
App42Response response =  timerService.deleteTimer(timerName);
System.out.println("Response is : " + response);
System.out.println("Success is : " + response.isResponseSuccess());
String timerName = "<Enter_your_timer_name>";
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.BuildTimerService();
timerService.DeleteTimer(timerName, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		App42Response app42Response = (App42Response)response;
		App42Log.Console ("App42Response is : " + app42Response.ToString());
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
var timerName = "<Enter_your_timer_name>";
App42.initialize("API_KEY","SECRET_KEY");
var timerService  = new App42Timer();
timerService.deleteTimer(name,{
success: function(object) {
	console.log("Response is : " +object)
},
error: function(error) {
}
});
local timerName = "<Enter_your_timer_name>";
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local timerService  = App42API:buildTimerService()
timerService:deleteTimer(timerName,App42CallBack)
function callBack:onSuccess(object)
	print("Response is"..object:getStrResponse());
end  
function App42CallBack:onException(exception)
	print("Message is : "..exception:getMessage())
	print("App Error code is : "..exception:getAppErrorCode())
	print("Http Error code is "..exception:getHttpErrorCode())
	print("Detail is : "..exception:getDetails())
end
const char* timerName = "<Enter_your_timer_name>";
const char* userName = "John";
App42API::Initialize("API_KEY", "SECRET_KEY");
TimerService *timerService = App42API::BuildTimerService();
timerService->DeleteTimer(timerName, app42callback(Sample_Class::onTimerServiceRequestCompleted, this));
void Sample_Class::onTimerServiceRequestCompleted( void *response)
{
    App42TimerResponse *app42TimerResponse = (App42TimerResponse*)response;
    if(app42TimerResponse->isSuccess)
    {
        printf("\ncode=%d",app42TimerResponse->getCode());
        printf("\nisSuccess=%d",app42TimerResponse->isSuccess);
        printf("\nResponse Body=%s",app42TimerResponse->getBody().c_str());
    }
    else
    {
        printf("\nerrordetails:%s",app42TimerResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",app42TimerResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",app42TimerResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",app42TimerResponse->httpErrorCode);
    }
}
Not Available
App42API::initialize("API_KEY","SECRET_KEY"); 
$timerService = App42API::buildTimerService(); 
$timerName = "<Enter_your_timer_name>";
$response = $timerService->deleteTimer($timerName);
print_r("Response is :  ".$response->toString());
$success = $response->isResponseSuccess();
$jsonResponse = $response->toString();  
Not Available
Not Available
var timerName:String = "<Enter_your_timer_name>";
App42API.initialize("API_KEY","SECRET_KEY");
var timerService:TimerService = App42API.buildTimerService(); 
timerService.deleteTimer(timerName,new callback());
class callback implements App42CallBack{
	public function onSuccess(response:Object):void
	{
		var app42response :App42Response= App42Response(response);    
		trace("response is " + app42response) 
	}
	public function onException(exception:App42Exception):void
	{
		trace("Exception Message " + exception);  
	}
}
Not Available
Not Available
Get Current Time

Fetch the current UTC time on server.

>
  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
TimerService timerService = App42API.buildTimerService();
timerService.getCurrentTime( new App42CallBack() {
public void onSuccess(Object response) 
{
	Timer timer = (Timer)response;      
	System.out.println("Current Time is:"+timer.getCurrentTime());
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
Not Available
[App42API initializeWithAPIKey:"APP_KEY" andSecretKey:"SECRET_KEY"];
TimerService *timerService = [App42API buildTimerService];
[timerService getCurrentTime:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		Timer *timer = (Timer*)responseObj;		
		NSLog(@"CurrentTime = %@",timer.currentTime);
	}
	else
	{
		NSLog(@"Exception = %@",[exception reason]);
		NSLog(@"HTTP error Code = %d",[exception httpErrorCode]);
		NSLog(@"App Error Code = %d",[exception appErrorCode]);
		NSLog(@"User Info = %@",[exception userInfo]);
	}
}];
App42API.initializeWithAPIKey("API_KEY", andSecretKey: "SECRET_KEY")
let timerService = App42API.buildTimerService() as! TimerService()
timerService?.getCurrentTime( { (success, response, exception) -> Void in
    if (success)
    {
        let timer = response as! Timer
        NSLog("CurrentTime = %@",timer.currentTime)
    }
    else
    {
        NSLog("%@", exception.reason!)
        NSLog("%d", exception.appErrorCode)
        NSLog("%d", exception.httpErrorCode)
    }  
})
App42API.initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.buildTimerService(); 
Timer timer = timerService.getCurrentTime();
System.out.println("Current Time is:"+timer.getCurrentTime());
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.BuildTimerService();
timerService.GetCurrentTime(new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Timer timer = (Timer)response;
		App42Log.Console("Current Time is: " +timer.GetCurrentTime());
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
App42.initialize("API_KEY","SECRET_KEY");
var timerService  = new App42Timer();
var result;
time.getCurrentTime({
success: function(object) 
{
	var timerObj = JSON.parse(object);
	var result =timerObj.app42.response.timer;
	console.log("Current Time is:"+result.currentTime);
},
error: function(error) {
}
});
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local timerService  = App42API:buildTimerService()
timerService:getCurrentTime(App42CallBack)
function callBack:onSuccess(object)
	print("CurrentTime is:"..object:getCurrentTime());
end  
function App42CallBack:onException(exception)
	print("Message is : "..exception:getMessage())
	print("App Error code is : "..exception:getAppErrorCode())
	print("Http Error code is "..exception:getHttpErrorCode())
	print("Detail is : "..exception:getDetails())
end
const char* timerName = "<Enter_your_timer_name>";
const char* userName = "John";
App42API::Initialize("API_KEY", "SECRET_KEY");
TimerService *timerService = App42API::BuildTimerService();
timerService->GetCurrentTime(app42callback(Sample_Class::onTimerServiceRequestCompleted, this));
void Sample_Class::onTimerServiceRequestCompleted( void *response)
{
    App42TimerResponse *app42TimerResponse = (App42TimerResponse*)response;
    if(app42TimerResponse->isSuccess)
    {
        printf("\ncode=%d",app42TimerResponse->getCode());
        printf("\nisSuccess=%d",app42TimerResponse->isSuccess);
        printf("\nResponse Body=%s",app42TimerResponse->getBody().c_str());
        printf("\n TimerName =%s",app42TimerResponse->app42Timer.name.c_str());
        printf("\n userName =%s",app42TimerResponse->app42Timer.userName.c_str());
        printf("\n startTime =%s",app42TimerResponse->app42Timer.startTime.c_str());
        printf("\n endTime =%s",app42TimerResponse->app42Timer.endTime.c_str());
        printf("\n isTimerActive=%d",app42TimerResponse->app42Timer.isTimerActive);
    }
    else
    {
        printf("\nerrordetails:%s",app42TimerResponse->errorDetails.c_str());
        printf("\nerrorMessage:%s",app42TimerResponse->errorMessage.c_str());
        printf("\nappErrorCode:%d",app42TimerResponse->appErrorCode);
        printf("\nhttpErrorCode:%d",app42TimerResponse->httpErrorCode);
    }
}

Not Available
App42API::initialize("API_KEY","SECRET_KEY"); 
$timerService = App42API::buildTimerService(); 
$timer = $timerService->getCurrentTime();
print_r("Current Time is:" .$timer->getCurrentTime());
Not Available
Not Available
App42API.initialize("API_KEY","SECRET_KEY");
var timerService:TimerService = App42API.buildTimerService(); 
timerService.getCurrentTime(new callback());
class callback implements App42CallBack
{
	public function onSuccess(response:Object):void
	{
		var timer:Timer = Timer(response);
		trace("Current Time is: "+timer.getCurrentTime());
	}
	public function onException(exception:App42Exception):void
	{
		trace("Exception Message " + exception);  
	}
}
Not Available
Not Available
Exception Handling

The functions available under Timer API can throw some exceptions in abnormal conditions. For example, if a developer is starting a time for user in app/game with a timer name which is not in the database, the function will throw the App42Exception (as shown below) with the message as “Not Found” and the appErrorCode as “5000” and the details as “Timer does not exist”.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
String timerName = "GiftTimer";
String userName= "John";
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
TimerService timerService = App42API.buildTimerService();
timerService.startTimer(timerName, userName, new App42CallBack() {
public void onSuccess(Object response) 
{
	Timer timer = (Timer)response;      
	System.out.println("Timer name is:" + timer.getName());
	System.out.println("UserName is:" + timer.getUserName());
}
public void onException(Exception exception) 
{
	var appErrorCode:int = exception.getAppErrorCode();  
		var httpErrorCode:int = exception.getHttpErrorCode();  
		if(appErrorCode == 5000)
		{
			// NOT FOUND (Timer  does not exist.)
		}
		else if(appErrorCode  == 1401)
		{
			// handle here for Client is not authorized
		}
		else if(appErrorCode == 1500)
		{
			// handle here for Internal Server Error
		}
	}
}
});
 
Coming Soon
NSString *timerName = @"GiftTimer";
NSString *userName = @"John";
[App42API initializeWithAPIKey:"APP_KEY" andSecretKey:"SECRET_KEY"];
TimerService *timerService = [App42API buildTimerService];
[timerService startTimerWithName:timerName forUser:userName completionBlock:^(BOOL success, id responseObj, App42Exception *exception) 
{
	if (success)
	{
		Timer *timer = (Timer*)responseObj;		
		NSLog(@"TimerName = %@",timer.name);
	}
	else
	{
		int appErrorCode = [exception appErrorCode];
		if(appErrorCode == 5000)
		{
			// NOT FOUND (Timer  does not exist.)
		}
		else if(appErrorCode == 1401)
		{
			// handle here for Client is not authorized
		}
		else if(appErrorCode == 1500)
		{
			// handle here for Internal Server Error
		}
	}
}];              
Coming Soon
String timerName = "GiftTimer";
String userName= "John";
App42API.initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.buildTimerService(); 
try 
{  
	Timer timer = timerService.startTimer(timerName, userName);
} 
catch(App42Exception exception) 
{  
	int appErrorCode = exception.getAppErrorCode();  
	int httpErrorCode = exception.getHttpErrorCode();  
	if(appErrorCode == 5000)
	{
		// NOT FOUND (Timer  does not exist.)
	}
	else if(appErrorCode == 1401)
	{
		// handle here for Client is not authorized
	}
	else if(appErrorCode == 1500)
	{
		// handle here for Internal Server Error
	}
	String jsonText = exception.getMessage();    
} 
String timerName = "GiftTimer";
String userName= "John";
App42Log.SetDebug(true);		//Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
TimerService timerService =  App42API.BuildTimerService();
timerService.StartTimer(timerName, userName, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Timer timer = (Timer) response;
		App42Log.Console("Response is " + timer.ToString());
	}
	public void OnException(Exception e)
	{	
		App42Exception exception = (App42Exception)e;
		int appErrorCode = exception.GetAppErrorCode();
		int httpErrorCode = exception.GetHttpErrorCode();
		if(appErrorCode == 5000)
		{
			// NOT FOUND (Timer  does not exist.)
		}
		else if(appErrorCode == 1401)
		{
			// handle here for Client is not authorized
		}
		else if(appErrorCode == 1500)
		{
			// handle here for Internal Server Error
		}
		String jsonText = exception.GetMessage();   
	}
}
var timerName = "GiftTimer" , 
userName= "John";
App42.initialize("API_KEY","SECRET_KEY");
var timerService  = new App42Timer();
timerService.startTimer(timerName, userName,{
	success: function(object) 
	{
	},
	error: function(error) {
	var timerObj = JSON.parse(object);  
        appErrorCode = timerObj.app42Fault.appErrorCode;
        if(appErrorCode == 5000)
		{
			// NOT FOUND (Timer  does not exist.)
		}
        else if(appErrorCode == 1401)
        {
            // handle here for Client is not authorized
        }
        else if(appErrorCode == 1500)
        {
            // handle here for Internal Server Error
        }
	}
});
local timerName = "GiftTimer";
local userName= "John";
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local timerService  = App42API:buildTimerService()
timerService:startTimer(timerName,userName,App42CallBack)
function App42CallBack:onSuccess(object)
	print("Response Success is "..object:getResponseSuccess())
end
function App42CallBack:onException(exception)
	local appErrorCode = exception:getAppErrorCode()
	if appErrorCode == 5000 then
		-- Timer  does not exist.
	elseif appErrorCode == 1401 then
		-- handle here for Client is not authorized
	elseif appErrorCode == 1500 then
		-- handle here for Internal Server Error
	end
end
Coming Soon
Coming Soon
$timerName = "GiftTimer";
$userName= "John";
App42API::initialize("API_KEY","SECRET_KEY"); 
$timerService = App42API::buildTimerService(); 
try
{	
	$timer = $timerService->startTimer($timerName, $userName);
} catch(App42Exception $exception) 
{
	$appErrorCode =$exception->getAppErrorCode();
	$httpErrorCode = $exception->getHttpErrorCode();
	if($appErrorCode == 5000)
	{
		// NOT FOUND (Timer  does not exist.)
	}
	else if($appErrorCode == 1401){
		// handle here for Client is not authorized
	}
	else if($appErrorCode == 1500){
		// handle here for Internal Server Error
	}
	$jsonText = $exception->getMessage(); 	
}
Coming Soon
Coming Soon
var timerName:String = "GiftTimer";
var userName:String= "John";
App42API.initialize("API_KEY","SECRET_KEY");
var timerService:TimerService = App42API.buildTimerService(); 
timerService.startTimer(timerName,userName,new callback());
public class callback implements App42CallBack  
{   
	public function onSuccess(response:Object):void  
	{  
		var timer:Timer = Timer(response);
		trace("Timer Name is :  "+timer.getName());
		trace("User name :" +timer.getUserName());		
		trace("Current Time :" +timer.getCurrentTime());
	} 
	public function onException(exception:App42Exception):void  
	{  
		var appErrorCode:int = exception.getAppErrorCode();  
		var httpErrorCode:int = exception.getHttpErrorCode();  
		if(appErrorCode== 5000)
		{
			// NOT FOUND (Timer  does not exist.)
		}
		else if(appErrorCode  == 1401)
		{
			// handle here for Client is not authorized
		}
		else if(appErrorCode == 1500)
		{
			// handle here for Internal Server Error
		}
	}  	
}  
Coming Soon
Coming Soon
Error Codes

Functions in Timer API might throw exceptions with following HTTP and Application Error Codes (along with their descriptions):

1400 - BAD REQUEST - The requested parameters are invalid. 1401 - UNAUTHORIZED - Client is not authorized. 1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again. 5000 - NOT FOUND - Timer does not exist. 5001 - BAD REQUEST - Timer already active. 5002 - BAD REQUEST - Timer already expired/cancelled.