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

@@ -21,15 +21,17 @@ class InboundCallSession extends CallSession {
this.req = req;
this.res = res;
req.on('cancel', () => {
this._notifyCallStatusChange({callStatus: CallStatus.NoAnswer, sipStatus: 487});
this._callReleased();
});
req.once('cancel', this._onCancel.bind(this));
this.on('callStatusChange', this._notifyCallStatusChange.bind(this));
this._notifyCallStatusChange({callStatus: CallStatus.Trying, sipStatus: 100});
}
_onCancel() {
this._notifyCallStatusChange({callStatus: CallStatus.NoAnswer, sipStatus: 487});
this._callReleased();
}
_onTasksDone() {
if (!this.res.finalResponseSent) {
if (this._mediaServerFailure) {
@@ -45,6 +47,7 @@ class InboundCallSession extends CallSession {
this.res.send(603);
}
}
this.req.removeAllListeners('cancel');
}
/**
@@ -56,6 +59,7 @@ class InboundCallSession extends CallSession {
this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration});
this.logger.debug('InboundCallSession: caller hung up');
this._callReleased();
this.req.removeAllListeners('cancel');
}
}