send callStatus completed event when REST call is ended with BYE generated from jambonz (#4)

This commit is contained in:
Dave Horton
2020-03-08 12:51:49 +00:00
parent 480817264d
commit f3926d2c9c

View File

@@ -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();
}