diff --git a/helper/Schedule.js b/helper/Schedule.js index 4f9ff34..e44da43 100644 --- a/helper/Schedule.js +++ b/helper/Schedule.js @@ -3,7 +3,7 @@ const schedule = require("node-schedule"); MCSERVER.Schedule = {}; MCSERVER.Schedule.container = {}; - +//循环型任务 module.exports.createScheduleJob = (id, time, callback) => { let mask = MCSERVER.Schedule.container[id] = schedule.scheduleJob(time, (fireDate) => { let res = callback(); @@ -13,9 +13,7 @@ module.exports.createScheduleJob = (id, time, callback) => { }); } - - - +//计次型任务 module.exports.createScheduleJobCount = (id, time, callback, count) => { let lco = 0; let mask = MCSERVER.Schedule.container[id] = schedule.scheduleJob(time, (fireDate) => { @@ -29,4 +27,12 @@ module.exports.createScheduleJobCount = (id, time, callback, count) => { mask.cancel(); } }); +} + +//删除 +module.exports.deleteScheduleJob = (id) => { + let mask = MCSERVER.Schedule.container[id] || null; + if (mask) { + mask.cancel(); + } } \ No newline at end of file