fix issue where multiple gathers running simultaneously (#321)

This commit is contained in:
Dave Horton
2023-04-18 21:58:30 -04:00
committed by GitHub
parent 0356b996ba
commit a22bc8ea42

View File

@@ -529,7 +529,7 @@ class CallSession extends Emitter {
this.logger.info({currInput, newInput}, this.logger.info({currInput, newInput},
'CallSession:enableBotMode - restarting background gather to apply new input type'); 'CallSession:enableBotMode - restarting background gather to apply new input type');
this.backgroundGatherTask.sticky = false; this.backgroundGatherTask.sticky = false;
this.disableBotMode(); await this.disableBotMode();
} }
} }
this.backgroundGatherTask = task; this.backgroundGatherTask = task;
@@ -568,12 +568,12 @@ class CallSession extends Emitter {
this.logger.info({err, gather}, 'CallSession:enableBotMode - Error creating gather task'); this.logger.info({err, gather}, 'CallSession:enableBotMode - Error creating gather task');
} }
} }
disableBotMode() { async disableBotMode() {
this._bargeInEnabled = false; this._bargeInEnabled = false;
if (this.backgroundGatherTask) { if (this.backgroundGatherTask) {
try { try {
this.backgroundGatherTask.removeAllListeners(); this.backgroundGatherTask.removeAllListeners();
this.backgroundGatherTask.kill().catch((err) => {}); await this.backgroundGatherTask.kill();
} catch (err) {} } catch (err) {}
this.backgroundGatherTask = null; this.backgroundGatherTask = null;
} }
@@ -724,7 +724,7 @@ class CallSession extends Emitter {
} }
else { else {
this.logger.info('CallSession:exec disabling bot mode to start gather with new options'); this.logger.info('CallSession:exec disabling bot mode to start gather with new options');
this.disableBotMode(); await this.disableBotMode();
} }
} }
if (!skip) { if (!skip) {