mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-01-25 02:07:56 +00:00
Fix for play issue (#1223)
See https://github.com/jambonz/jambonz-feature-server/issues/1222
This commit is contained in:
@@ -83,6 +83,7 @@ class CallSession extends Emitter {
|
|||||||
this.stickyEventEmitter = new StickyEventEmitter();
|
this.stickyEventEmitter = new StickyEventEmitter();
|
||||||
this.stickyEventEmitter.onSuccess = () => {
|
this.stickyEventEmitter.onSuccess = () => {
|
||||||
this.taskInProgress = null;
|
this.taskInProgress = null;
|
||||||
|
this.stickyEventEmitter.destroy();
|
||||||
};
|
};
|
||||||
this.backgroundTaskManager = new BackgroundTaskManager({
|
this.backgroundTaskManager = new BackgroundTaskManager({
|
||||||
cs: this,
|
cs: this,
|
||||||
@@ -1927,10 +1928,12 @@ Duration=${duration} `
|
|||||||
this.stackIdx++;
|
this.stackIdx++;
|
||||||
this.logger.debug({tasks: listTaskNames(tasks)},
|
this.logger.debug({tasks: listTaskNames(tasks)},
|
||||||
`CallSession:replaceApplication reset with ${tasks.length} new tasks, stack depth is ${this.stackIdx}`);
|
`CallSession:replaceApplication reset with ${tasks.length} new tasks, stack depth is ${this.stackIdx}`);
|
||||||
|
let curTaskKilled = false;
|
||||||
if (this.currentTask) {
|
if (this.currentTask) {
|
||||||
this.logger.debug('CallSession:replaceApplication - killing current task ' +
|
this.logger.debug('CallSession:replaceApplication - killing current task ' +
|
||||||
this.currentTask?.name + ', taskId: ' + this.currentTask.taskId);
|
this.currentTask?.name + ', taskId: ' + this.currentTask.taskId);
|
||||||
this.currentTask.kill(this, KillReason.Replaced);
|
this.currentTask.kill(this, KillReason.Replaced);
|
||||||
|
curTaskKilled = true;
|
||||||
this.currentTask = null;
|
this.currentTask = null;
|
||||||
}
|
}
|
||||||
else if (this.wakeupResolver) {
|
else if (this.wakeupResolver) {
|
||||||
@@ -1938,7 +1941,8 @@ Duration=${duration} `
|
|||||||
this.wakeupResolver({reason: 'new tasks'});
|
this.wakeupResolver({reason: 'new tasks'});
|
||||||
this.wakeupResolver = null;
|
this.wakeupResolver = null;
|
||||||
}
|
}
|
||||||
if ((!this.currentTask || this.currentTask === undefined) && this.isCurTaskPlay) {
|
// if currentTask which is play, already got killed, no need to call uuid_break
|
||||||
|
if (!curTaskKilled && (!this.currentTask || this.currentTask === undefined) && this.isCurTaskPlay) {
|
||||||
this.logger.debug(`CallSession:replaceApplication - emitting uuid_break, taskId: ${this.taskInProgress?.taskId}`);
|
this.logger.debug(`CallSession:replaceApplication - emitting uuid_break, taskId: ${this.taskInProgress?.taskId}`);
|
||||||
this.stickyEventEmitter.emit('uuid_break', this.taskInProgress);
|
this.stickyEventEmitter.emit('uuid_break', this.taskInProgress);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ class StickyEventEmitter extends EventEmitter {
|
|||||||
this.onSuccess();
|
this.onSuccess();
|
||||||
}
|
}
|
||||||
this._onceListeners.delete(event);
|
this._onceListeners.delete(event);
|
||||||
|
// return from here as the event listener is already called
|
||||||
|
// this is to avoid calling the native emit method which
|
||||||
|
// will call the event listener again
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.emit(event, ...args);
|
return super.emit(event, ...args);
|
||||||
|
|||||||
Reference in New Issue
Block a user