Compare commits

...
3 Commits
4 changed files with 42 additions and 25 deletions
+20 -7
View File
@@ -84,6 +84,20 @@ class CallSession extends Emitter {
return this.req.has('X-Five9-StreamingPairId');
}
subscribeForDTMF(dlg) {
if (!this._subscribedForDTMF) {
this._subscribedForDTMF = true;
this.subscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uas.tag,
this._onDTMF.bind(this, dlg));
}
}
unsubscribeForDTMF() {
if (this._subscribedForDTMF) {
this._subscribedForDTMF = false;
this.unsubscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uas.tag);
}
}
async connect() {
const {sdp} = this.req.locals;
this.logger.info('inbound call accepted for routing');
@@ -290,8 +304,7 @@ class CallSession extends Emitter {
_setDlgHandlers(dlg) {
const {callId} = dlg.sip;
this.activeCallIds.set(callId, this);
this.subscribeDTMF(this.logger, callId, this.rtpEngineOpts.uas.tag,
this._onDTMF.bind(this));
this.subscribeForDTMF(dlg);
dlg.on('destroy', () => {
debug('call ended with normal termination');
this.logger.info('call ended with normal termination');
@@ -339,7 +352,8 @@ class CallSession extends Emitter {
try {
await other.destroy();
} catch (err) {}
this.unsubscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uas.tag);
this.unsubscribeForDTMF();
const trackingOn = process.env.JAMBONES_TRACK_ACCOUNT_CALLS ||
process.env.JAMBONES_TRACK_SP_CALLS ||
@@ -395,8 +409,7 @@ class CallSession extends Emitter {
});
});
this.subscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uas.tag,
this._onDTMF.bind(this, uac));
this.subscribeForDTMF(uac);
uas.on('modify', this._onReinvite.bind(this, uas));
uac.on('modify', this._onReinvite.bind(this, uac));
@@ -490,7 +503,7 @@ Duration=${payload.duration} `
});
}
this.unsubscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uas.tag);
this.unsubscribeForDTMF();
const uas = await this.srf.createUAS(req, res, {
localSdp: response.sdp,
@@ -883,7 +896,7 @@ Duration=${payload.duration} `
// successfully connected
this.logger.info('successfully connected new call leg for REFER');
this.unsubscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uas.tag);
this.unsubscribeForDTMF();
this.referInvite = null;
sendNotify(this.uas, '200 OK');
this.uas.destroy();
+6 -2
View File
@@ -2,7 +2,7 @@ const debug = require('debug')('jambonz:sbc-inbound');
const assert = require('assert');
const Emitter = require('events');
const parseUri = require('drachtio-srf').parseUri;
const {nudgeCallCounts} = require('./utils');
const {nudgeCallCounts, roundTripTime} = require('./utils');
const msProxyIps = process.env.MS_TEAMS_SIP_PROXY_IPS ?
process.env.MS_TEAMS_SIP_PROXY_IPS.split(',').map((i) => i.trim()) :
[];
@@ -135,7 +135,8 @@ module.exports = function(srf, logger) {
const identifyAccount = async(req, res, next) => {
try {
const {siprec, callId} = req.locals;
const {getSPForAccount, wasOriginatedFromCarrier, getApplicationForDidAndCarrier} = req.srf.locals;
const {getSPForAccount, wasOriginatedFromCarrier, getApplicationForDidAndCarrier, stats} = req.srf.locals;
const startAt = process.hrtime();
const {
fromCarrier,
gateway,
@@ -144,6 +145,9 @@ module.exports = function(srf, logger) {
service_provider_sid,
account
} = await wasOriginatedFromCarrier(req);
const rtt = roundTripTime(startAt);
stats.histogram('app.mysql.response_time', rtt, [
'query:wasOriginatedFromCarrier', 'app:sbc-inbound']);
/**
* calls come from 3 sources:
* (1) A carrier
+14 -14
View File
@@ -9,11 +9,11 @@
"version": "v0.7.7",
"license": "MIT",
"dependencies": {
"@jambonz/db-helpers": "^0.7.0",
"@jambonz/db-helpers": "^0.7.2",
"@jambonz/http-authenticator": "^0.2.2",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/realtimedb-helpers": "^0.4.35",
"@jambonz/rtpengine-utils": "^0.3.10",
"@jambonz/rtpengine-utils": "^0.3.11",
"@jambonz/siprec-client-utils": "^0.1.4",
"@jambonz/stats-collector": "^0.1.6",
"@jambonz/time-series": "^0.2.5",
@@ -572,9 +572,9 @@
}
},
"node_modules/@jambonz/db-helpers": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.0.tgz",
"integrity": "sha512-Fj0q8qEwW2xKCtOyDkzKLl6kvBASFTeLljc+LW1hoF47pe+IFc3ZXPL3ntqwX39YgFCMayeUrJMdio+1GYsECA==",
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.2.tgz",
"integrity": "sha512-xFK6qNz4HebbNZsR35UnNptxeNKvfzu67UTdkVkBKOXW4O0nsVjwl5yuiacgXugHyCJ6Xq0dB3Cir4e52DAp6A==",
"dependencies": {
"cidr-matcher": "^2.1.1",
"debug": "^4.3.3",
@@ -634,9 +634,9 @@
}
},
"node_modules/@jambonz/rtpengine-utils": {
"version": "0.3.10",
"resolved": "https://registry.npmjs.org/@jambonz/rtpengine-utils/-/rtpengine-utils-0.3.10.tgz",
"integrity": "sha512-nwnHaS4vKkj5YB9HyB06ZyHu5knhSzAOeg4qMG4GS0joRAx7DVmnuPhRaQJmcVAgZm9VuDfxSFQrGIot/oVBBQ==",
"version": "0.3.11",
"resolved": "https://registry.npmjs.org/@jambonz/rtpengine-utils/-/rtpengine-utils-0.3.11.tgz",
"integrity": "sha512-+WDZrAje2ww7zBY2+DYgPdiDg+Uh9qC4B/+EfQ/ghjseausaUWhUCDuJOdFQtHXA1qtEiMxTD1argeC5DtJBYQ==",
"dependencies": {
"debug": "^4.3.1",
"rtpengine-client": "^0.3.9",
@@ -6203,9 +6203,9 @@
"dev": true
},
"@jambonz/db-helpers": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.0.tgz",
"integrity": "sha512-Fj0q8qEwW2xKCtOyDkzKLl6kvBASFTeLljc+LW1hoF47pe+IFc3ZXPL3ntqwX39YgFCMayeUrJMdio+1GYsECA==",
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.7.2.tgz",
"integrity": "sha512-xFK6qNz4HebbNZsR35UnNptxeNKvfzu67UTdkVkBKOXW4O0nsVjwl5yuiacgXugHyCJ6Xq0dB3Cir4e52DAp6A==",
"requires": {
"cidr-matcher": "^2.1.1",
"debug": "^4.3.3",
@@ -6259,9 +6259,9 @@
}
},
"@jambonz/rtpengine-utils": {
"version": "0.3.10",
"resolved": "https://registry.npmjs.org/@jambonz/rtpengine-utils/-/rtpengine-utils-0.3.10.tgz",
"integrity": "sha512-nwnHaS4vKkj5YB9HyB06ZyHu5knhSzAOeg4qMG4GS0joRAx7DVmnuPhRaQJmcVAgZm9VuDfxSFQrGIot/oVBBQ==",
"version": "0.3.11",
"resolved": "https://registry.npmjs.org/@jambonz/rtpengine-utils/-/rtpengine-utils-0.3.11.tgz",
"integrity": "sha512-+WDZrAje2ww7zBY2+DYgPdiDg+Uh9qC4B/+EfQ/ghjseausaUWhUCDuJOdFQtHXA1qtEiMxTD1argeC5DtJBYQ==",
"requires": {
"debug": "^4.3.1",
"rtpengine-client": "^0.3.9",
+2 -2
View File
@@ -25,11 +25,11 @@
"jslint": "eslint app.js lib"
},
"dependencies": {
"@jambonz/db-helpers": "^0.7.0",
"@jambonz/db-helpers": "^0.7.2",
"@jambonz/realtimedb-helpers": "^0.4.35",
"@jambonz/http-authenticator": "^0.2.2",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/rtpengine-utils": "^0.3.10",
"@jambonz/rtpengine-utils": "^0.3.11",
"@jambonz/siprec-client-utils": "^0.1.4",
"@jambonz/stats-collector": "^0.1.6",
"@jambonz/time-series": "^0.2.5",