diff --git a/src/Registrator.js b/src/Registrator.js index 0c81537cb..dc1f72695 100644 --- a/src/Registrator.js +++ b/src/Registrator.js @@ -36,7 +36,7 @@ JsSIP.Registrator = function(ua, transport) { // Contact header if(reg_id) { - this.contact = '<' + this.ua.contact.uri + '>'; + this.contact = this.ua.contact.toString(); this.contact += ';reg-id='+ reg_id; this.contact += ';+sip.instance=""'; } else { diff --git a/src/Session.js b/src/Session.js index 54ef6e7aa..c67f632dc 100644 --- a/src/Session.js +++ b/src/Session.js @@ -59,7 +59,7 @@ JsSIP.Session.prototype.init_incoming = function(request) { this.from_tag = request.from_tag; this.id = request.call_id + this.from_tag; this.request = request; - this.contact = '<'+ this.ua.contact +'>'; + this.contact = this.ua.contact.toString(); //Save the session into the ua sessions collection. this.ua.sessions[this.id] = this; @@ -126,16 +126,17 @@ JsSIP.Session.prototype.connect = function(target, views, options) { requestParams = {from_tag: this.from_tag}; - if (options.anonymous) { - this.contact = '<'+ this.ua.contact.toString(true) +';ob>'; + this.contact = this.ua.contact.toString({ + anonymous: this.anonymous, + outbound: true + }); + if (this.anonymous) { requestParams.from_display_name = 'Anonymous'; requestParams.from_uri = 'sip:anonymous@anonymous.invalid'; extraHeaders.push('P-Preferred-Identity: '+ this.ua.configuration.uri.toString()); extraHeaders.push('Privacy: id'); - } else { - this.contact = '<'+ this.ua.contact +';ob>'; } extraHeaders.push('Contact: '+ this.contact); diff --git a/src/UA.js b/src/UA.js index 9a2826bd5..5c2128d80 100644 --- a/src/UA.js +++ b/src/UA.js @@ -715,14 +715,26 @@ JsSIP.UA.prototype.loadConfig = function(configuration) { pub_gruu: null, temp_gruu: null, uri: new JsSIP.URI('sip', JsSIP.Utils.createRandomToken(8), settings.via_host, null, {transport: 'ws'}), - toString: function(anonymous){ - var contact; + toString: function(options){ + options = options || {}; + + var + anonymous = options.anonymous || null, + outbound = options.outbound || null, + contact = '<'; if (anonymous) { - contact = this.temp_gruu || 'sip:anonymous@anonymous.invalid;transport=ws'; + contact += this.temp_gruu || 'sip:anonymous@anonymous.invalid;transport=ws'; } else { - contact = this.pub_gruu || this.uri.toString(); + contact += this.pub_gruu || this.uri.toString(); + } + + if (outbound) { + contact += ';ob'; } + + contact += '>'; + return contact; } };