Comments (3)
Depending on the event and whether the channel has entered Stasis, you may have to register for events before they are automatically subscribed to. Can you provide more details or code to show what you are trying to accomplish?
from node-ari-client.
I am trying to originate a call using originate() function, and i bind for 'channelStateChange' , i print originated channel state i.e. logger.log(channel.state) , it printing state as 'Rsrvd', but 'channelStateChange' not emitting .
it emitting for some event like 'Ringing', 'Dialing' etc.
my code is :----->
'use strict';
var ari = require('ari-client');
var logger = require('mylogger');
var ARI_HOST = 'xxx.xxx.xxx.xxx';
var ARI_PORT = 1234;
var ARI_USER = '***********';
var ARI_PASS = '**********';
var appName = 'app123';
function ChannelStateChange(event, channel) {
logger.log('channel ChannelStateChange:---->', channel.id);
logger.log('event:---->', channel.state);
}
ari.connect('http://' + ARI_HOST + ':' + ARI_PORT, ARI_USER, ARI_PASS, clientLoaded);
function clientLoaded(err, client) {
if (err) {
logger.error(err);
}
client.on('StasisStart', function (event, channel) {
if (channel.dialplan.exten != "") {
logger.log('statsis started !!!!!!!!!!!!!!!!!!!!!');
}
});
client.on('StasisEnd', function (event, channel) {
logger.info('statsis END !!!!!!!!!!!!!!!!!!!!!')
});
client.on('ChannelStateChange', ChannelStateChange);
client.start(appName);
client.channels.originate(
{endpoint: "DAHDI/g0/9876543210", app: appName, appArgs: 'dialed', callerId: '+12343567324'},
function (err, channel) {
if(err){
return console.log(err);
}
channel.on('StasisStart', function (event, channel) {
console.log('StasisStart channel.state:',channel.state);
});
channel.on('ChannelHangupRequest', function (event, channel) {
console.log('ChannelHangupRequest channel.state:',channel.state);
});
channel.on('ChannelDestroyed', function (event, channel) {
console.log('ChannelDestroyed channel.state:',channel.state);
});
console.log('channel-originate state:',channel.state)
console.log('channel-originate with channelId:',channel.id)
}
);
}
from node-ari-client.
With originate
you won't see all events until the channel enters stasis.
You can use something like the following to register for events for the channel, but again, you have to wait for the channel to exist, so you might miss events in between the channel being created and you registering for events:
client.applications.subscribe({
applicationName: appName,
eventSource: 'channel:' + channel.id
})
Another option would be to use client.channels.create
[1] followed by client.channels.dial
[2]. This allows creating a channel which auto subscribes you to events. You can then listen for any event you wish before calling dial
to originate the call.
Feel free to reopen this issue if that doesn't fix your issues.
[1] https://github.com/asterisk/node-ari-client#create-1
[2] https://github.com/asterisk/node-ari-client#dial
from node-ari-client.
Related Issues (20)
- Playback not found HOT 2
- ARI Feature Request "BackGroundDetect"
- BridgeDestroyed event not captured
- Trying to connect to an unreachable host doesn't always throw an error
- Upgrading swagger HOT 4
- ari.recordings.getStoredFile(): SyntaxError: Unexpected token R in JSON at position 0 HOT 1
- Unable to received dtmf input after certain level
- Final dialstatus of dialed channel
- Client disconnection without warnings
- Can i use originate for outbound call using sip trunk HOT 1
- can't read swagger JSON HOT 4
- Can i add member to queue? HOT 1
- Warnings on deprecated libraries and dependencies when installed on Node V12.22.09 HOT 1
- How to remove sound of connection from person listened with snoopChannel?
- setChannelVar HOT 3
- Error: Channel not found on hangup HOT 4
- EventEmitter(catch like 'StasisStart') HOT 1
- Asterisk ARI Issue HOT 24
- snoopChannel - Channel not in Stasis application
- How can i create an application from FreePBX
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-ari-client.