Timer and Scheduling Service

Set up timers which will fire events once, on an interval, or on a schedule.

Operations

Events

Operations


cancel

This operation will cancel an active timer.

Arguments
parameters - object - Object containing service call parameters.
Name Type Description
timer_id string The ID of the timer to cancel
Responses
Operation successful - object
Name Type Description
result string Okay if successful
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.sendAfter({timer_id="exampleId",duration=100}) print(req) req = Timer.cancel({timer_id="exampleId"}) print(req)

cancelAll

This operation will cancel all active timers in the given solution.

Responses
Operation successful - object
Name Type Description
result string Okay if successful
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.cancelAll() print(req)

list

This operation will list all active timers in the given solution.

Responses
All timers information - object
Name Type Description
list [ string ] A list of timer id.
result string A message describing the result of the operation
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.list() print(req)

sendAfter

Sets up a timer which will fire once after duration has passed.

Arguments
parameters - object - Object containing service call parameters.
Name Type Description
message string, object The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
duration integer The duration of the timer in milliseconds.
timer_id string The ID of the timer. If null, it will be generated for you.
Responses
New timer task information - object
Name Type Description
result string A message describing the result of the operation
timer_id string The ID of the timer
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.sendAfter({timer_id="abc123", duration=100}) print(req) response.message = req response.code = 200

sendInterval

Sets up a timer which will fire once every duration.

Arguments
parameters - object - Object containing service call parameters.
Name Type Description
message string, object The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
duration integer The duration of the timer in milliseconds.
timer_id string The ID of the timer. If null, it will be generated for you.
Responses
New timer task information - object
Name Type Description
result string A message describing the result of the operation
timer_id string The ID of the timer
Operation error information - object
Name Type Description
type string Error type
error string Error message
status integer Response code
Example
local req = Timer.sendInterval({timer_id="abc123", duration=100}) print(req) response.message = req response.code = 200

Events


timer

A scheduled timer is occurring. And timer task data is transmitted.

Arguments
request - object - The timer task data
Name Type Description
message object The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
timer_id string The ID of the timer. If null, it will be generated for you.
solution_id string The ID of the solution this timer is associated with.
Example
function handle_timer_timer (request)

 -- Your logic comes here 

end