add pause command

This commit is contained in:
Dave Horton committed 2020-02-03 20:51:50 -05:00
1 parent 348a820044
commit 2811e35c6b
6 files changed
+46

No files matched your search

+3
View File
@@ -30,6 +30,9 @@ function makeTask(logger, obj) {
case TaskName.Play:
const TaskPlay = require('./play');
return new TaskPlay(logger, data);
case TaskName.Pause:
const TaskPause = require('./pause');
return new TaskPause(logger, data);
case TaskName.Gather:
const TaskGather = require('./gather');
return new TaskGather(logger, data);
+26
View File
@@ -0,0 +1,26 @@
const Task = require('./task');
const {TaskName} = require('../utils/constants');
class TaskPause extends Task {
constructor(logger, opts, parentTask) {
super(logger, opts);
this.length = this.data.length;
}
get name() { return TaskName.Pause; }
async exec(cs, ep) {
super.exec(cs);
this.timer = setTimeout(this.notifyTaskDone.bind(this), this.length * 1000);
await this.awaitTaskDone();
}
async kill() {
super.kill();
clearTimeout(this.timer);
this.notifyTaskDone();
}
}
module.exports = TaskPause;
+8
View File
@@ -108,6 +108,14 @@
"url"
]
},
"pause": {
"properties": {
"length": "number"
},
"required": [
"length"
]
},
"redirect": {
"properties": {
"action": "string",
+1
View File
@@ -4,6 +4,7 @@
"Gather": "gather",
"Hangup": "hangup",
"Listen": "listen",
"Pause": "pause",
"Play": "play",
"Redirect": "redirect",
"RestDial": "rest:dial",