mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
add pause command
This commit is contained in:
26
lib/tasks/pause.js
Normal file
26
lib/tasks/pause.js
Normal 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;
|
||||
Reference in New Issue
Block a user