bugfix: cs not passed to kill()

This commit is contained in:
Dave Horton
2021-09-28 09:58:59 -04:00
parent 4bc3e03605
commit a3d3878218

View File

@@ -94,7 +94,7 @@ class TaskGather extends Task {
}
if (this.input.includes('digits')) {
ep.on('dtmf', this._onDtmf.bind(this, ep));
ep.on('dtmf', this._onDtmf.bind(this, cs, ep));
}
await this.awaitTaskDone();
@@ -108,19 +108,19 @@ class TaskGather extends Task {
kill(cs) {
super.kill(cs);
this._killAudio();
this._killAudio(cs);
this.ep.removeAllListeners('dtmf');
this._resolve('killed');
}
_onDtmf(ep, evt) {
_onDtmf(cs, ep, evt) {
this.logger.debug(evt, 'TaskGather:_onDtmf');
if (evt.dtmf === this.finishOnKey) this._resolve('dtmf-terminator-key');
else {
this.digitBuffer += evt.dtmf;
if (this.digitBuffer.length === this.numDigits) this._resolve('dtmf-num-digits');
}
this._killAudio();
this._killAudio(cs);
}
async _initSpeech(cs, ep) {
@@ -191,14 +191,14 @@ class TaskGather extends Task {
}
}
_killAudio() {
_killAudio(cs) {
if (this.sayTask && !this.sayTask.killed) {
this.sayTask.removeAllListeners('playDone');
this.sayTask.kill();
this.sayTask.kill(cs);
}
if (this.playTask && !this.playTask.killed) {
this.playTask.removeAllListeners('playDone');
this.playTask.kill();
this.playTask.kill(cs);
}
}