fix overlapping requests to freeswitch on outdial

This commit is contained in:
Dave Horton
2020-08-03 11:51:30 -04:00
parent 884e63e0ef
commit 2c8c161954
2 changed files with 14 additions and 9 deletions

View File

@@ -154,6 +154,10 @@ class TaskGather extends Task {
this.resolved = true; this.resolved = true;
this.logger.debug(`TaskGather:resolve with reason ${reason}`); this.logger.debug(`TaskGather:resolve with reason ${reason}`);
if (this.ep && this.ep.connected) {
this.ep.stopTranscription().catch((err) => this.logger.error({err}, 'Error stopping transcription'));
}
this._clearTimer(); this._clearTimer();
if (reason.startsWith('dtmf')) { if (reason.startsWith('dtmf')) {
await this.performAction({digits: this.digitBuffer}); await this.performAction({digits: this.digitBuffer});

View File

@@ -108,13 +108,11 @@ class SingleDialer extends Emitter {
this.ep = await ms.createEndpoint(); this.ep = await ms.createEndpoint();
this.logger.debug(`SingleDialer:exec - created endpoint ${this.ep.uuid}`); this.logger.debug(`SingleDialer:exec - created endpoint ${this.ep.uuid}`);
let sdp; let promiseStreamConnected;
const connectStream = async(remoteSdp) => { const connectStream = async(remoteSdp) => {
if (remoteSdp !== sdp) { // wait for previous re-invite to complete, if any
this.ep.modify(sdp = remoteSdp); if (promiseStreamConnected) await promiseStreamConnected.catch((err) => {});
return true; return promiseStreamConnected = this.ep.modify(remoteSdp);
}
return false;
}; };
Object.assign(opts, { Object.assign(opts, {
@@ -153,14 +151,17 @@ class SingleDialer extends Emitter {
cbProvisional: (prov) => { cbProvisional: (prov) => {
const status = {sipStatus: prov.status}; const status = {sipStatus: prov.status};
if ([180, 183].includes(prov.status) && prov.body) { if ([180, 183].includes(prov.status) && prov.body) {
if (status.callStatus !== CallStatus.EarlyMedia) {
status.callStatus = CallStatus.EarlyMedia; status.callStatus = CallStatus.EarlyMedia;
if (connectStream(prov.body)) this.emit('earlyMedia'); this.emit('earlyMedia');
}
connectStream(prov.body);
} }
else status.callStatus = CallStatus.Ringing; else status.callStatus = CallStatus.Ringing;
this.emit('callStatusChange', status); this.emit('callStatusChange', status);
} }
}); });
connectStream(this.dlg.remote.sdp); await connectStream(this.dlg.remote.sdp);
this.dlg.callSid = this.callSid; this.dlg.callSid = this.callSid;
this.inviteInProgress = null; this.inviteInProgress = null;
this.emit('callStatusChange', {sipStatus: 200, callStatus: CallStatus.InProgress}); this.emit('callStatusChange', {sipStatus: 200, callStatus: CallStatus.InProgress});