mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
fix overlapping requests to freeswitch on outdial
This commit is contained in:
@@ -108,13 +108,11 @@ class SingleDialer extends Emitter {
|
||||
|
||||
this.ep = await ms.createEndpoint();
|
||||
this.logger.debug(`SingleDialer:exec - created endpoint ${this.ep.uuid}`);
|
||||
let sdp;
|
||||
let promiseStreamConnected;
|
||||
const connectStream = async(remoteSdp) => {
|
||||
if (remoteSdp !== sdp) {
|
||||
this.ep.modify(sdp = remoteSdp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// wait for previous re-invite to complete, if any
|
||||
if (promiseStreamConnected) await promiseStreamConnected.catch((err) => {});
|
||||
return promiseStreamConnected = this.ep.modify(remoteSdp);
|
||||
};
|
||||
|
||||
Object.assign(opts, {
|
||||
@@ -153,14 +151,17 @@ class SingleDialer extends Emitter {
|
||||
cbProvisional: (prov) => {
|
||||
const status = {sipStatus: prov.status};
|
||||
if ([180, 183].includes(prov.status) && prov.body) {
|
||||
status.callStatus = CallStatus.EarlyMedia;
|
||||
if (connectStream(prov.body)) this.emit('earlyMedia');
|
||||
if (status.callStatus !== CallStatus.EarlyMedia) {
|
||||
status.callStatus = CallStatus.EarlyMedia;
|
||||
this.emit('earlyMedia');
|
||||
}
|
||||
connectStream(prov.body);
|
||||
}
|
||||
else status.callStatus = CallStatus.Ringing;
|
||||
this.emit('callStatusChange', status);
|
||||
}
|
||||
});
|
||||
connectStream(this.dlg.remote.sdp);
|
||||
await connectStream(this.dlg.remote.sdp);
|
||||
this.dlg.callSid = this.callSid;
|
||||
this.inviteInProgress = null;
|
||||
this.emit('callStatusChange', {sipStatus: 200, callStatus: CallStatus.InProgress});
|
||||
|
||||
Reference in New Issue
Block a user