mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 09:54:11 +00:00
21 lines
419 B
Plaintext
21 lines
419 B
Plaintext
|
contract EventTimer{
|
||
|
function onCreate() {
|
||
|
Global.timers = {};
|
||
|
}
|
||
|
|
||
|
export function init() {
|
||
|
YancloudUtil.subscribe("timer", handler);
|
||
|
return "done";
|
||
|
}
|
||
|
|
||
|
export function get(tag) {
|
||
|
if (tag && Global.timers[tag]) {
|
||
|
return String(Global.timers[tag]);
|
||
|
}
|
||
|
return JSON.stringify(Global.timers);
|
||
|
}
|
||
|
|
||
|
function handler(e) {
|
||
|
Global.timers[e.content] = new Date().getTime();
|
||
|
}
|
||
|
}
|