diff --git a/lib/session/rest-call-session.js b/lib/session/rest-call-session.js index fdb122bf..113ed381 100644 --- a/lib/session/rest-call-session.js +++ b/lib/session/rest-call-session.js @@ -32,6 +32,14 @@ class RestCallSession extends CallSession { this.dlg = dlg; dlg.on('destroy', this._callerHungup.bind(this)); dlg.connectTime = moment(); + + const origDestroy = dlg.destroy.bind(dlg); + dlg.destroy = () => { + const duration = moment().diff(this.dlg.connectTime, 'seconds'); + this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration}); + this.logger.debug('RestCallSession: call terminated by jambones'); + origDestroy(); + }; } /** @@ -40,7 +48,7 @@ class RestCallSession extends CallSession { _callerHungup() { const duration = moment().diff(this.dlg.connectTime, 'seconds'); this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration}); - this.logger.debug('InboundCallSession: caller hung up'); + this.logger.debug('RestCallSession: called party hung up'); this._callReleased(); }