diff --git a/lib/tasks/conference.js b/lib/tasks/conference.js index 2132a63e..1a6a8e79 100644 --- a/lib/tasks/conference.js +++ b/lib/tasks/conference.js @@ -108,6 +108,10 @@ class Conference extends Task { async kill(cs) { super.kill(cs); this.logger.info(`Conference:kill ${this.confName}`); + if (this._playSession) { + this._playSession.kill(); + this._playSession = null; + } this.emitter.emit('kill'); await this._doFinalMemberCheck(cs); if (this.ep && this.ep.connected) this.ep.conn.removeAllListeners('esl::event::CUSTOM::*') ; @@ -427,13 +431,19 @@ class Conference extends Task { .catch((err) => this.logger.info({err}, 'Error deafing or undeafing participant')); } + if (wait_hook) { + if (this.wait_hook) + delete this.wait_hook.url; + this.wait_hook = {url: wait_hook}; + } + if (hookOnly && this._playSession) { this._playSession.kill(); this._playSession = null; } - if (wait_hook && this.conf_hold_status === 'hold') { + if (this.wait_hook?.url && this.conf_hold_status === 'hold') { const {dlg} = cs; - this._doWaitHookWhileOnHold(cs, dlg, wait_hook); + this._doWaitHookWhileOnHold(cs, dlg, this.wait_hook); } else if (this.conf_hold_status !== 'hold' && this._playSession) { this._playSession.kill(); @@ -444,7 +454,9 @@ class Conference extends Task { async _doWaitHookWhileOnHold(cs, dlg, wait_hook) { do { try { - const tasks = await this._playHook(cs, dlg, wait_hook); + let tasks = []; + if (wait_hook.url) + tasks = await this._playHook(cs, dlg, wait_hook.url); if (0 === tasks.length) break; } catch (err) { if (!this.killed) { @@ -571,6 +583,10 @@ class Conference extends Task { */ _kicked(cs, dlg) { this.logger.info(`Conference:kicked - I was dropped from conference ${this.confName}, task is complete`); + if (this._playSession) { + this._playSession.kill(); + this._playSession = null; + } this.replaceEndpointAndEnd(cs); }