Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/opentok.js
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,10 @@ OpenTok.prototype.dial = function (sessionId, token, sipUri, options, callback)
body.sip.observeForceMute = !!options.observeForceMute;
}

if (options.streams) {
body.sip.streams = options.streams;
}

this.client.dial(body, function (err, json) {
if (err) return callback(new Error('Failed to dial endpoint. ' + err));
return callback(null, new SipInterconnect(self, json));
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "opentok",
"version": "2.21.2",
"version": "2.22.0",
"description": "OpenTok server-side SDK",
"homepage": "https://github.com/opentok/opentok-node",
"bugs": {
Expand Down
48 changes: 48 additions & 0 deletions test/opentok-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,54 @@ describe('#dial', function () {
this.token = this.opentok.generateToken(this.sessionId);
});

it('dials a SIP gateway and explicitely adds a stream', function (done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-opentok-auth', function (value) {
try {
jwt.verify(value[0], apiSecret, { issuer: apiKey });
return true;
}
catch (error) {
done(error);
return false;
}
})
.matchHeader('user-agent', new RegExp('OpenTok-Node-SDK/' + pkg.version))
.post('/v2/project/123456/dial', {
sessionId: this.sessionId,
token: this.token,
sip: {
uri: goodSipUri,
streams: ["stream-id-1"]
},
})
.reply(200, {
id: 'CONFERENCEID',
connectionId: 'CONNECTIONID',
streamId: 'STREAMID'
});
this.opentok.dial(
this.sessionId,
this.token,
goodSipUri,
{
streams: ['stream-id-1']
},
function (err, sipCall) {
if (err) {
done(err);
return;
}
expect(sipCall).to.be.an.instanceof(SipInterconnect);
expect(sipCall.id).to.equal('CONFERENCEID');
expect(sipCall.streamId).to.equal('STREAMID');
expect(sipCall.connectionId).to.equal('CONNECTIONID');
scope.done();
done(err);
}
);
});

it('dials a SIP gateway and adds a stream', function (done) {
var scope = nock('https://api.opentok.com:443')
.matchHeader('x-opentok-auth', function (value) {
Expand Down