mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
added redirect verb
This commit is contained in:
@@ -14,28 +14,31 @@ class CallSession extends Emitter {
|
||||
this.callSid = callSid;
|
||||
this.tasks = tasks;
|
||||
|
||||
this.taskIdx = 0;
|
||||
this.stackIdx = 0;
|
||||
this.callGone = false;
|
||||
}
|
||||
|
||||
async exec() {
|
||||
let idx = 0;
|
||||
this.logger.info(`CallSession:exec starting task list with ${this.tasks.length} tasks`);
|
||||
while (this.tasks.length && !this.callGone) {
|
||||
const taskNum = ++this.taskIdx;
|
||||
const stackNum = this.stackIdx;
|
||||
const task = this.tasks.shift();
|
||||
this.logger.debug({task}, `CallSession:exec starting task #${++idx}: ${task.name}`);
|
||||
this.logger.debug({task}, `CallSession:exec starting task #${stackNum}:${taskNum}: ${task.name}`);
|
||||
try {
|
||||
const resources = await this._evaluatePreconditions(task);
|
||||
this.currentTask = task;
|
||||
await task.exec(this, resources);
|
||||
this.currentTask = null;
|
||||
this.logger.debug(`CallSession:exec completed task #${idx}: ${task.name}`);
|
||||
this.logger.debug(`CallSession:exec completed task #${stackNum}:${taskNum}: ${task.name}`);
|
||||
} catch (err) {
|
||||
this.currentTask = null;
|
||||
if (err.message.includes(BADPRECONDITIONS)) {
|
||||
this.logger.info(`CallSession:exec task #${idx}: ${task.name}: ${err.message}`);
|
||||
this.logger.info(`CallSession:exec task #${stackNum}:${taskNum}: ${task.name}: ${err.message}`);
|
||||
}
|
||||
else {
|
||||
this.logger.error(err, `Error executing task #${idx}: ${task.name}`);
|
||||
this.logger.error(err, `Error executing task #${stackNum}:${taskNum}: ${task.name}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +67,9 @@ class CallSession extends Emitter {
|
||||
*/
|
||||
replaceApplication(tasks) {
|
||||
this.tasks = tasks;
|
||||
this.logger.info({tasks}, `CallSession:replaceApplication - set ${tasks.length} new tasks`);
|
||||
this.logger.info({tasks}, `CallSession:replaceApplication - reset application with ${tasks.length} new tasks`);
|
||||
this.taskIdx = 0;
|
||||
this.stackIdx++;
|
||||
}
|
||||
_evaluatePreconditions(task) {
|
||||
switch (task.preconditions) {
|
||||
|
||||
Reference in New Issue
Block a user