mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
clean up some retainers
This commit is contained in:
@@ -632,7 +632,7 @@ class CallSession extends Emitter {
|
|||||||
try {
|
try {
|
||||||
if (!this.ms) this.ms = this.getMS();
|
if (!this.ms) this.ms = this.getMS();
|
||||||
const ep = await this.ms.createEndpoint({remoteSdp: this.req.body});
|
const ep = await this.ms.createEndpoint({remoteSdp: this.req.body});
|
||||||
ep.cs = this;
|
//ep.cs = this;
|
||||||
this.ep = ep;
|
this.ep = ep;
|
||||||
ep.set({
|
ep.set({
|
||||||
hangup_after_bridge: false,
|
hangup_after_bridge: false,
|
||||||
@@ -716,14 +716,15 @@ class CallSession extends Emitter {
|
|||||||
/**
|
/**
|
||||||
* Hang up the call and free the media endpoint
|
* Hang up the call and free the media endpoint
|
||||||
*/
|
*/
|
||||||
async _clearResources() {
|
_clearResources() {
|
||||||
for (const resource of [this.dlg, this.ep]) {
|
for (const resource of [this.dlg, this.ep]) {
|
||||||
try {
|
if (resource && resource.connected) {
|
||||||
if (resource && resource.connected) await resource.destroy();
|
resource.destroy()
|
||||||
} catch (err) {
|
.catch((err) => this.logger.error(err, 'CallSession:_clearResources error'));
|
||||||
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)
|
// remove any temporary tts files that were created (audio is still cached in redis)
|
||||||
for (const path of this.tmpFiles) {
|
for (const path of this.tmpFiles) {
|
||||||
|
|||||||
@@ -21,15 +21,17 @@ class InboundCallSession extends CallSession {
|
|||||||
this.req = req;
|
this.req = req;
|
||||||
this.res = res;
|
this.res = res;
|
||||||
|
|
||||||
req.on('cancel', () => {
|
req.once('cancel', this._onCancel.bind(this));
|
||||||
this._notifyCallStatusChange({callStatus: CallStatus.NoAnswer, sipStatus: 487});
|
|
||||||
this._callReleased();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.on('callStatusChange', this._notifyCallStatusChange.bind(this));
|
this.on('callStatusChange', this._notifyCallStatusChange.bind(this));
|
||||||
this._notifyCallStatusChange({callStatus: CallStatus.Trying, sipStatus: 100});
|
this._notifyCallStatusChange({callStatus: CallStatus.Trying, sipStatus: 100});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onCancel() {
|
||||||
|
this._notifyCallStatusChange({callStatus: CallStatus.NoAnswer, sipStatus: 487});
|
||||||
|
this._callReleased();
|
||||||
|
}
|
||||||
|
|
||||||
_onTasksDone() {
|
_onTasksDone() {
|
||||||
if (!this.res.finalResponseSent) {
|
if (!this.res.finalResponseSent) {
|
||||||
if (this._mediaServerFailure) {
|
if (this._mediaServerFailure) {
|
||||||
@@ -45,6 +47,7 @@ class InboundCallSession extends CallSession {
|
|||||||
this.res.send(603);
|
this.res.send(603);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.req.removeAllListeners('cancel');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,6 +59,7 @@ class InboundCallSession extends CallSession {
|
|||||||
this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration});
|
this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration});
|
||||||
this.logger.debug('InboundCallSession: caller hung up');
|
this.logger.debug('InboundCallSession: caller hung up');
|
||||||
this._callReleased();
|
this._callReleased();
|
||||||
|
this.req.removeAllListeners('cancel');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -448,6 +448,12 @@ class TaskDial extends Task {
|
|||||||
this._killOutdials(); // NB: order is important
|
this._killOutdials(); // NB: order is important
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onMaxCallDuration(cs) {
|
||||||
|
this.logger.info(`Dial:_onMaxCallDuration tearing down call as it has reached ${this.timeLimit}s`);
|
||||||
|
this.ep && this.ep.unbridge();
|
||||||
|
this.kill(cs);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We now have a call leg produced by the Dial action, so
|
* We now have a call leg produced by the Dial action, so
|
||||||
* - hangup any simrings in progress
|
* - hangup any simrings in progress
|
||||||
@@ -468,11 +474,7 @@ class TaskDial extends Task {
|
|||||||
await cs.propagateAnswer();
|
await cs.propagateAnswer();
|
||||||
}
|
}
|
||||||
if (this.timeLimit) {
|
if (this.timeLimit) {
|
||||||
this.timerMaxCallDuration = setTimeout(() => {
|
this.timerMaxCallDuration = setTimeout(this._onMaxCallDuration.bind(this, cs), this.timeLimit * 1000);
|
||||||
this.logger.info(`Dial:_selectSingleDial tearing down call as it has reached ${this.timeLimit}s`);
|
|
||||||
this.ep && this.ep.unbridge();
|
|
||||||
this.kill(cs);
|
|
||||||
}, this.timeLimit * 1000);
|
|
||||||
}
|
}
|
||||||
sessionTracker.add(this.callSid, cs);
|
sessionTracker.add(this.callSid, cs);
|
||||||
this.dlg.on('destroy', () => {
|
this.dlg.on('destroy', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user