Closed VasylDmytruk closed 5 years ago
It's been a while since I've worked with endpoints, but I believe you have to subscribe to endpoint events in order to receive them.
Something like:
ari.applications.subscribe({
// your app name
applicationName: 'app',
// https://wiki.asterisk.org/wiki/display/AST/Asterisk+15+Applications+REST+API#Asterisk15ApplicationsRESTAPI-subscribe
eventSource: `endpoint:${endpoint. technology}/${endpoint.resource}`
}).then(() => {})
.catch((err) => {});
Thank you very much! It works!!!
Could you also tell how to handle theses events:
ari.on('StasisStart', function (event, channel) {
console.log('StasisStart', channel);
});
ari.on('StasisEnd', function (event, channel) {
console.log('StasisEnd', channel);
});
My code is:
var client = require('ari-client');
client.connect('http://localhost:8088', 'my-username', 'my-password')
.then(function (ari) {
ari.on('StasisStart', function (event, channel) {
// doesn't work
console.log('StasisStart', channel);
});
ari.on('StasisEnd', function (event, channel) {
// doesn't work
console.log('StasisEnd', channel);
});
ari.start('app');
})
.catch(function (err) {
console.error('error', err);
});
I try to handle endpoint state change. I connect to asterisk via Zoiper and see in list of endpoints that
state
of myresource
changed from'offline'
to'online'
. And when I exit from Zoiper vice versa from'online'
to'offline'
. I can see this in list of endpoints:I want to see
state
change in eventEndpointStateChange
:What I am doing wrong?