Skip to content

Commit

Permalink
Fix the way stun servers configuration is generated.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Feb 3, 2013
1 parent ef6c3b0 commit 72424bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/MediaSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,24 @@ JsSIP.MediaSession.prototype = {
* @param {Function} onSuccess Fired when there are no more ICE candidates
*/
start: function(onSuccess) {
var idx, server,
var idx, server, scheme, url,
session = this,
sent = false,
servers = [];

for (idx in this.session.ua.configuration.stun_servers) {
server = this.session.ua.configuration.stun_server[idx];
server = this.session.ua.configuration.stun_servers[idx];
servers.push({'url': server});
}

for (idx in this.session.ua.configuration.turn_servers) {
server = this.session.ua.configuration.turn_servers[idx];
servers.push({'url': server.username +'@'+ server.server, 'credential': server.password});
url = server.server;
scheme = url.substr(0, url.indexOf(':'));
servers.push({
'url': scheme + ':' + server.username + '@' + url.substr(scheme.length+1),
'credential': server.password
});
}

this.peerConnection = new webkitRTCPeerConnection({"iceServers": servers});
Expand Down
4 changes: 2 additions & 2 deletions src/UA.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,11 @@ JsSIP.UA.prototype.loadConfig = function(configuration) {
}
}

if (!(configuration.stun_servers instanceof Array)){
if (configuration.stun_servers && !(configuration.stun_servers instanceof Array)){
configuration.stun_servers = [configuration.stun_servers];
}

if (!(configuration.turn_servers instanceof Array)){
if (configuration.turn_servers && !(configuration.turn_servers instanceof Array)){
configuration.turn_servers = [configuration.turn_servers];
}

Expand Down

0 comments on commit 72424bd

Please sign in to comment.