mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
Feat/902: executing giveUpAction when noResponseGiveupTimeout is reached (#908)
* feat/893: made noResponseTimeout and noResponseGiveUpTimout independent * support for giveUpActions implemented * feat/902: using makeTask and exec of task to execute the giveUpActions * feat/902: changed version of verb-specifications and speech-utils * feat/902: fixed jslint errors * feat/902: modified log * feat/902: using a new event giveupWithTasks for processing giveUpActions * feat/902: removed check for wakeupResolver and replaceApplication already taking care of wakeupResolver, also updated the verb-specifications version * feat/902: removed sync for _onNoResponseGiveUpTimer function
This commit is contained in:
@@ -544,6 +544,17 @@ class CallSession extends Emitter {
|
||||
this.wakeupResolver = null;
|
||||
}
|
||||
});
|
||||
this._actionHookDelayProcessor.on('giveupWithTasks', (tasks) => {
|
||||
this.logger.info('CallSession: ActionHookDelayProcessor: giveupWithTasks event');
|
||||
const giveUpTasks = normalizeJambones(this.logger, tasks).map((tdata) => makeTask(this.logger, tdata));
|
||||
this.logger.info({tasks: listTaskNames(giveUpTasks)}, 'CallSession:giveupWithTasks task list');
|
||||
|
||||
// we need to clear the ahd, as we do not want to execute actionHookDelay actions again
|
||||
this.clearActionHookDelayProcessor();
|
||||
|
||||
// replace the application with giveUpTasks
|
||||
this.replaceApplication(giveUpTasks);
|
||||
});
|
||||
} catch (err) {
|
||||
this.logger.error({err}, 'CallSession: Error creating ActionHookDelayProcessor');
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class ActionHookDelayProcessor extends Emitter {
|
||||
this.retries = opts.retries || 0;
|
||||
this.noResponseTimeout = opts.noResponseTimeout;
|
||||
this.noResponseGiveUpTimeout = opts.noResponseGiveUpTimeout;
|
||||
this.giveUpActions = opts.giveUpActions;
|
||||
|
||||
// return false if these options actually disable the ahdp
|
||||
return ('enable' in opts && opts.enable === true) ||
|
||||
@@ -165,9 +166,14 @@ class ActionHookDelayProcessor extends Emitter {
|
||||
|
||||
_onNoResponseGiveUpTimer() {
|
||||
this._active = false;
|
||||
this.logger.info('ActionHookDelayProcessor#_onNoResponseGiveUpTimer');
|
||||
this.stop().catch((err) => {});
|
||||
this.emit('giveup');
|
||||
if (!this.giveUpActions) {
|
||||
this.logger.info('ActionHookDelayProcessor#_onNoResponseGiveUpTimer');
|
||||
this.stop().catch((err) => {});
|
||||
this.emit('giveup');
|
||||
} else {
|
||||
this.logger.info('ActionHookDelayProcessor#_onNoResponseGiveUpTimer - giveUpActions');
|
||||
this.emit('giveupWithTasks', this.giveUpActions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user