Now I am developing third party server using node.js and GCM. My app story is that first client choose time. My server push message on this time. I tryied using node-schedule but I can't find how to cancel the specific schedule. how to handle schedule job . e.g. 5 client select 5 pm to push message. but one client want to change time and the other one client want to cancel pushing message . how to change time and cancel specific client's time using schedule job.
现在我正在使用node开发第三方服务器。js和GCM。我的应用故事是第一个客户选择时间。此时,我的服务器推送消息。我用的是节点计划,但是我找不到如何取消特定的计划。如何处理计划工作。5客户端选择5 pm推送消息。但是一个客户想要改变时间,另一个客户想要取消推送消息。如何利用日程安排工作改变时间和取消特定客户的时间。
1 个解决方案
#1
3
You need to give a name to your Schedule task.
你需要给你的计划任务命名。
So first here's how you schedule a task with node-schedule
首先,我们来看看如何用node-schedule安排一个任务
var schedule = require('node-schedule');
var date = new Date();
date.setMinutes(date.getMinutes() + 2);
schedule.scheduleJob('hereisthename', date, function(params)
{
//Tasks to execute
}.bind(null, params));
It will schedule a task that going to be executed in two minutes with the name "hereisthename"
它会安排一个任务在两分钟内执行,名字是"hereisthename"
then if you want to cancel it
如果你想取消它
var scheduled = schedule.scheduledJobs;
if (scheduled['hereisthename'] != null)
scheduled['hereisthename'].cancel();
#1
3
You need to give a name to your Schedule task.
你需要给你的计划任务命名。
So first here's how you schedule a task with node-schedule
首先,我们来看看如何用node-schedule安排一个任务
var schedule = require('node-schedule');
var date = new Date();
date.setMinutes(date.getMinutes() + 2);
schedule.scheduleJob('hereisthename', date, function(params)
{
//Tasks to execute
}.bind(null, params));
It will schedule a task that going to be executed in two minutes with the name "hereisthename"
它会安排一个任务在两分钟内执行,名字是"hereisthename"
then if you want to cancel it
如果你想取消它
var scheduled = schedule.scheduledJobs;
if (scheduled['hereisthename'] != null)
scheduled['hereisthename'].cancel();