mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 00:58:34 +00:00
kill play task if bot responds verbs while actionHook delay is enabled (#712)
* kill play task if bot responds verbs while actionHook delay is enabled * fix actionHook delay continues even the bot already responded verbs * wip * wip * wip
This commit is contained in:
@@ -2269,6 +2269,7 @@ Duration=${duration} `
|
||||
|
||||
_startActionHookNoResponseTimer(options) {
|
||||
this._clearActionHookNoResponseTimer();
|
||||
this._actionHookDelayResolved = false;
|
||||
if (options.noResponseTimeoutMs) {
|
||||
this.logger.debug(`CallSession:_startActionHookNoResponseTimer ${options.noResponseTimeoutMs}`);
|
||||
this._actionHookNoResponseTimer = setTimeout(() => {
|
||||
@@ -2282,7 +2283,9 @@ Duration=${duration} `
|
||||
if (t.length) {
|
||||
t[0].on('playDone', (err) => {
|
||||
if (err) this.logger.error({err}, `Call-Session:exec Error delay action, play ${verb}`);
|
||||
if (!this._actionHookDelayResolved) {
|
||||
this._startActionHookNoResponseTimer(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.tasks.push(...t);
|
||||
@@ -2300,7 +2303,16 @@ Duration=${duration} `
|
||||
|
||||
_clearActionHookNoResponseTimer() {
|
||||
if (this._actionHookNoResponseTimer) {
|
||||
// Action Hook delay is solved.
|
||||
this._actionHookDelayResolved = true;
|
||||
clearTimeout(this._actionHookNoResponseTimer);
|
||||
// if delay action is enabled
|
||||
// and bot has responded with list of new verbs
|
||||
// Only kill current running play task.
|
||||
//https://github.com/jambonz/jambonz-feature-server/issues/710
|
||||
if (this.currentTask?.name === TaskName.Play) {
|
||||
this.currentTask.kill(this);
|
||||
}
|
||||
}
|
||||
this._actionHookNoResponseTimer = null;
|
||||
}
|
||||
|
||||
@@ -250,8 +250,7 @@ class TaskConfig extends Task {
|
||||
cs.stopBackgroundTask('transcribe');
|
||||
}
|
||||
}
|
||||
|
||||
if (this.actionHookDelayAction) {
|
||||
if (Object.keys(this.actionHookDelayAction).length !== 0) {
|
||||
cs.actionHookDelayEnabled = this.actionHookDelayAction.enabled || false;
|
||||
cs.actionHookNoResponseTimeout = this.actionHookDelayAction.noResponseTimeout || 0;
|
||||
cs.actionHookNoResponseGiveUpTimeout = this.actionHookDelayAction.noResponseGiveUpTimeout || 0;
|
||||
|
||||
Reference in New Issue
Block a user