asterisk / node-ari-client

Node.js client for ARI. This library is best effort with limited support.
Other
250 stars 98 forks source link

how to get call originate event #77

Closed mpbanna closed 7 years ago

mpbanna commented 7 years ago

how to get current status of a call originate in ARI,means staus of call-originated is at -> local end is ringing OR remote end is ringing OR remote end is busy etc.

samuelg commented 7 years ago

The ChannelStateChange event on a channel is what you need for this.

The callback you provide should have the following signature:

function (event, channel) {
  // channel.state will contain the state of the channel
}

Please note that you will have to subscribe to early channel events using the following:

client.applications.subscribe({
  applicationName: 'name',  // replace with your application name
  eventSource: 'channel:id'  // replace with your channel ID
})

If you use originate, you can only subscribe after you fire the origination, which means you can potentially miss some early events due to timing issues. It would be better to use client.channels.create followed by client.channels.dial for this. Using create+dial will auto subscribe to early channel events as well.

mpbanna commented 7 years ago

Thank you for solution, i use ari.channels.create() then ari.channels.dial() but it gives type error: /usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/async.js:43 fn = function () { throw arg; }; ^

TypeError: client.channels.create is not a function at clientLoaded (/usr/local/lib/node_modules/sarvIVR/IVR/mahi_callTransfer.js:163:25) at tryCatcher (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/util.js:26:23) at Promise.successAdapter (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/nodeify.js:23:30) at Promise._settlePromiseAt (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/promise.js:582:21) at Promise._settlePromises (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/promise.js:700:14) at Async._drainQueue (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/async.js:123:16) at Async._drainQueues (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/async.js:133:10) at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/async.js:15:14) at processImmediate [as _immediateCallback] (timers.js:383:17)