Skip to content

Commit

Permalink
Fix #164. Initialize 'registrator' in the 'UA' constructor. Thanks @n…
Browse files Browse the repository at this point in the history
…ilsonfreitas

- registrator is an internal UA element which must be initializated in the constructor
  • Loading branch information
jmillan committed Sep 27, 2013
1 parent e67b5a9 commit 714f503
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/UA.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ UA = function(configuration) {

this.configuration = {};
this.dialogs = {};
this.registrator = null;
this.registrator = new JsSIP.Registrator(this);

//User actions outside any session/dialog (MESSAGE)
this.applicants = {};
Expand Down Expand Up @@ -199,7 +199,7 @@ UA.prototype.unregister = function(options) {
* @param {Boolean}
*/
UA.prototype.isRegistered = function() {
if(this.registrator && this.registrator.registered) {
if(this.registrator.registered) {
return true;
} else {
return false;
Expand Down Expand Up @@ -275,10 +275,8 @@ UA.prototype.stop = function() {
}

// Close registrator
if(this.registrator) {
this.logger.log('closing registrator');
this.registrator.close();
}
this.logger.log('closing registrator');
this.registrator.close();

// Run _terminate_ on every Session
for(session in this.sessions) {
Expand Down Expand Up @@ -466,14 +464,7 @@ UA.prototype.onTransportConnected = function(transport) {
});

if(this.configuration.register) {
if(this.registrator) {
this.registrator.onTransportConnected();
} else {
this.registrator = new JsSIP.Registrator(this, transport);
this.register();
}
} else if (!this.registrator) {
this.registrator = new JsSIP.Registrator(this, transport);
this.registrator.onTransportConnected();
}
};

Expand Down Expand Up @@ -712,9 +703,7 @@ UA.prototype.closeSessionsOnTransportError = function() {
this.sessions[idx].onTransportError();
}
// Call registrator _onTransportClosed_
if(this.registrator){
this.registrator.onTransportClosed();
}
this.registrator.onTransportClosed();
};

UA.prototype.recoverTransport = function(ua) {
Expand Down

0 comments on commit 714f503

Please sign in to comment.