const CallSession = require('./call-session'); const {CallStatus} = require('../utils/constants'); const moment = require('moment'); class RestCallSession extends CallSession { constructor({logger, application, srf, req, ep, tasks, callInfo}) { super({ logger, application, srf, callSid: callInfo.callSid, tasks, callInfo }); this.req = req; this.ep = ep; } setDialog(dlg) { this.dlg = dlg; dlg.on('destroy', this._callerHungup.bind(this)); dlg.connectTime = moment(); } _callerHungup() { const duration = moment().diff(this.dlg.connectTime, 'seconds'); this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration}); this.logger.debug('InboundCallSession: caller hung up'); this._callReleased(); } } module.exports = RestCallSession;