Notify Event not available
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
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
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
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
That should be the correct example for everyone
What if i want to subscribe for multiple uri
?