mirror of
https://github.com/jambonz/sbc-outbound.git
synced 2026-07-04 19:32:04 +00:00
bugfix: invites to the PSTN and to webrtc clients
This commit is contained in:
+18
-3
@@ -58,8 +58,14 @@ class CallSession extends Emitter {
|
||||
debug(`connecting call: ${JSON.stringify(this.req.locals)}`);
|
||||
if (this.req.locals.registration) {
|
||||
debug(`sending call to user ${JSON.stringify(this.req.locals.registration)}`);
|
||||
proxy = this.req.locals.registration.contact;
|
||||
uris = [this.req.uri];
|
||||
const contact = this.req.locals.registration.contact;
|
||||
if (contact.includes('transport=ws')) {
|
||||
uris = [contact];
|
||||
}
|
||||
else {
|
||||
proxy = this.req.locals.registration.contact;
|
||||
uris = [this.req.uri];
|
||||
}
|
||||
}
|
||||
else if (this.req.locals.target === 'forward') {
|
||||
uris = [this.req.uri];
|
||||
@@ -73,6 +79,11 @@ class CallSession extends Emitter {
|
||||
this.req.calledNumber;
|
||||
uris = await this.performLcr(routableNumber);
|
||||
if (!uris || uris.length === 0) throw new Error('no routes found');
|
||||
uris = uris.map((uri) => {
|
||||
this.logger.debug(`uri: ${uri}`);
|
||||
const arr = /^(.*):(\d+)$/.exec(uri);
|
||||
return arr ? `sip:${routableNumber}@${arr[1]}:${arr[2]}` : uri;
|
||||
});
|
||||
} catch (err) {
|
||||
debug(err);
|
||||
this.logger.error(err, 'Error performing lcr');
|
||||
@@ -243,7 +254,11 @@ class CallSession extends Emitter {
|
||||
res.send(202);
|
||||
|
||||
// invite to new fs
|
||||
const dlg = await this.srf.createUAC(referTo.uri, {localSdp: dlg.local.sdp});
|
||||
const headers = {};
|
||||
if (req.has('X-Retain-Call-Sid')) {
|
||||
Object.assign(headers, {'X-Retain-Call-Sid': req.get('X-Retain-Call-Sid')});
|
||||
}
|
||||
const dlg = await this.srf.createUAC(referTo.uri, {localSdp: dlg.local.sdp, proxyRequestHeaders});
|
||||
this.uas.destroy();
|
||||
|
||||
this.uas = dlg;
|
||||
|
||||
Reference in New Issue
Block a user