simplify handling of reinvites from feature server

This commit is contained in:
Dave Horton committed 2020-04-24 16:20:20 -04:00
1 parent 2c751a0b36
commit de64af278d
1 file changed
+17 -3
+17 -3
View File
@@ -154,10 +154,9 @@ class CallSession extends Emitter {
this.rtpEngineResource.destroy();
this.activeCallIds.delete(this.req.get('Call-ID'));
});
//re-invite
dlg.on('modify', this._onReinvite.bind(this, dlg));
});
uas.on('modify', this._onReinvite.bind(this, uas));
uac.on('modify', this._onFeatureServerReinvite.bind(this, uac));
// default forwarding of other request types
forwardInDialogRequests(uas);
@@ -184,6 +183,21 @@ class CallSession extends Emitter {
}
}
async _onFeatureServerReinvite(dlg, req, res) {
try {
const opts = Object.assign({sdp: req.body, 'to-tag': res.getParsedHeader('To').params.tag},
this.rtpEngineOpts.answer);
const response = await this.answer(opts);
if ('ok' !== response.result) {
res.send(488);
throw new Error(`_onFeatureServerReinvite: rtpengine failed: ${JSON.stringify(response)}`);
}
res.send(200, {body: response.sdp});
} catch (err) {
this.logger.error(err, 'Error handling reinvite from feature server');
}
}
}
module.exports = CallSession;