clean up some retainers

This commit is contained in:
Dave Horton
2021-12-09 10:44:50 -05:00
parent c190279927
commit 10382573fa
3 changed files with 22 additions and 15 deletions

View File

@@ -632,7 +632,7 @@ class CallSession extends Emitter {
try {
if (!this.ms) this.ms = this.getMS();
const ep = await this.ms.createEndpoint({remoteSdp: this.req.body});
ep.cs = this;
//ep.cs = this;
this.ep = ep;
ep.set({
hangup_after_bridge: false,
@@ -716,14 +716,15 @@ class CallSession extends Emitter {
/**
* Hang up the call and free the media endpoint
*/
async _clearResources() {
_clearResources() {
for (const resource of [this.dlg, this.ep]) {
try {
if (resource && resource.connected) await resource.destroy();
} catch (err) {
this.logger.error(err, 'CallSession:_clearResources error');
if (resource && resource.connected) {
resource.destroy()
.catch((err) => this.logger.error(err, 'CallSession:_clearResources error'));
}
}
this.dlg = null;
this.ep = null;
// remove any temporary tts files that were created (audio is still cached in redis)
for (const path of this.tmpFiles) {