prevent calling dlg.destroy twice

This commit is contained in:
Dave Horton
2020-03-09 22:17:44 +00:00
parent f7a76733a1
commit afc1fd3639

View File

@@ -567,10 +567,14 @@ class CallSession extends Emitter {
dlg.connectTime = moment(); dlg.connectTime = moment();
const origDestroy = dlg.destroy.bind(dlg); const origDestroy = dlg.destroy.bind(dlg);
dlg.destroy = () => { dlg.destroy = () => {
if (dlg.connected) {
dlg.connected = false;
dlg.destroy = origDestroy;
const duration = moment().diff(this.dlg.connectTime, 'seconds'); const duration = moment().diff(this.dlg.connectTime, 'seconds');
this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration}); this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration});
this.logger.debug('CallSession: call terminated by jambones'); this.logger.debug('CallSession: call terminated by jambones');
if (dlg.connected) origDestroy(); origDestroy();
}
}; };
} }