clean up handlers

This commit is contained in:
Dave Horton
2021-12-15 19:33:31 -05:00
parent afbbed3f5c
commit 2b9cb5105f
2 changed files with 14 additions and 0 deletions

View File

@@ -235,10 +235,19 @@ class TaskDial extends Task {
}
}
_removeHandlers(sd) {
sd.removeAllListeners('accept');
sd.removeAllListeners('decline');
sd.removeAllListeners('adulting');
sd.removeAllListeners('callStatusChange');
sd.removeAllListeners('callCreateFail');
}
_killOutdials() {
for (const [callSid, sd] of Array.from(this.dials)) {
this.logger.debug(`Dial:_killOutdials killing callSid ${callSid}`);
sd.kill().catch((err) => this.logger.info(err, `Dial:_killOutdials Error killing ${callSid}`));
this._removeHandlers(sd);
}
this.dials.clear();
}