Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsSIP.UA connected event enhancements #164

Closed
pontello opened this issue Sep 26, 2013 · 2 comments
Closed

JsSIP.UA connected event enhancements #164

pontello opened this issue Sep 26, 2013 · 2 comments

Comments

@pontello
Copy link

Lets suppose that I have user agent with option register=false

var uac = new JsSIP.UA({ register : false});

In my understand, if connected event is fired, I am able register, for example:

uac.once('connected', function(e){
    uac.register();
});

But unfortunately it is crashing inside following method ( this.registrator is NULL):

UA.prototype.register = function(options) {
  this.configuration.register = true;
  this.registrator.register(options);
};

It crashes because not all internal variables are initialized. I have to do something like following code to make it work:

uac.once('connected', function(e){
    setTimeout(function(){
        uac.register();
    }, 0);
});

My suggestion is to change internal implementation to allow us to register after connected without use timeout hacks...

@ibc
Copy link
Member

ibc commented Sep 26, 2013

Indeed a bug. Not sure if this happens in more places. A solution would be to make all the events to fire their code within a setTimeout(function(){ XXX }, 0).

@jmillan
Copy link
Member

jmillan commented Sep 27, 2013

@ibc, you are very right. And I remember you already suggested me so. I've applied such change in the event emitter for the #163 issue patch.

Thank you

jmillan added a commit that referenced this issue Nov 13, 2013
…ilsonfreitas

- registrator is an internal UA element which must be initializated in the constructor
jmillan added a commit that referenced this issue Nov 13, 2013
…ilsonfreitas

- registrator is an internal UA element which must be initializated in the constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants