SIP.js icon indicating copy to clipboard operation
SIP.js copied to clipboard

Notify Event not available

Open Djcd opened this issue 12 years ago • 5 comments

When i try to use your example from http://sipjs.com/api/0.5.0/subscription/#events

i get

sip.ua | unable to add a listener to a nonexistent event notify sip-0.5.0.js:168
TypeError: Invalid or uninitialized event: notify
    at Object.EventEmitter.on (http://localhost:8080/js/sip-0.5.0.js:321:13)
    at new homeController (http://localhost:8080/app/controllers/homeController.js:6:19)

Greetings Djcd

Djcd avatar Apr 28 '14 23:04 Djcd

Hi Djcd,

I think the example code block shown at http://sipjs.com/api/0.5.0/subscription/#examples was incorrect. Please try this instead:

//Subscribes to the presence information of [email protected]
var subscription = myUA.subscribe('[email protected]', 'presence');

// Once subscribed, receive notifications and print out the presence information
subscription.on('notify', function (notification) {
  console.log(notification.body);
});

Let us know how it goes!

Joseph

josephfrazier avatar Apr 28 '14 23:04 josephfrazier

Hi Joseph,

Thanks for the fast reply! That new example makes more sense and it works just fine:

//Subscribes to the presence information of [email protected]
var subscription = userAgent.subscribe('[email protected]', 'presence');

// Once subscribed, receive notifications and print out the presence information
subscription.on('notify', function (notification) {
    console.log(notification.request.body);
});

Thx again, Djcd

Djcd avatar Apr 29 '14 00:04 Djcd

I'm glad to hear you got it working! I'll update the example code accordingly. Please feel free to ask about any other issues you run into.

Joseph

josephfrazier avatar Apr 29 '14 00:04 josephfrazier

That should be the correct example for everyone

Djcd avatar Apr 29 '14 11:04 Djcd

What if i want to subscribe for multiple uri code ?

umasgn avatar Dec 08 '16 18:12 umasgn