mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-07-04 19:11:47 +00:00
fix for dtmf handler when running multiple instances on same EC2
This commit is contained in:
+20
-7
@@ -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();
|
||||
|
||||
Generated
+7
-7
@@ -13,7 +13,7 @@
|
||||
"@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",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
"@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",
|
||||
|
||||
Reference in New Issue
Block a user