Skip to content
Permalink
Browse files

Fix #60, #61. Add optional parameters to ua.contact.toString(). Thanks

…@ibc

- anonymous (boolean)
- outbound (boolean)
  • Loading branch information
jmillan committed Feb 17, 2013
1 parent 8f5acb1 commit f19842b1ea5385371f770ff70d03820aae213d24
Showing with 23 additions and 10 deletions.
  1. +1 −1 src/Registrator.js
  2. +6 −5 src/Session.js
  3. +16 −4 src/UA.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="<urn:uuid:'+ this.ua.configuration.instance_id+'>"';
} else {
@@ -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);
@@ -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;
}
};

2 comments on commit f19842b

@ibc

This comment has been minimized.

Copy link
Member

ibc replied Feb 17, 2013

🍰

@jmillan

This comment has been minimized.

Copy link
Member Author

jmillan replied Feb 17, 2013

;-)

Please sign in to comment.
You can’t perform that action at this time.