agi-node icon indicating copy to clipboard operation
agi-node copied to clipboard

channel emits 'hangup' event on hangup

Open mattdimeo opened this issue 7 years ago • 0 comments

This change causes the agi channel object to emit a hangup event when the channel is hung up.

The use case is when the AGI is waiting for something to happen elsewhere in the system, and needs to handle a hangup event as an exceptional case. For example, the AGI has sent a push notification to a mobile application, and is waiting for an asynchronous reply before continuing. The agi would continue when the asynchronous reply happens, or alternately send a cancellation push notification when the caller hangs up.

Contrived example:

(function waitForHangup(cb) {
    someOtherEmitter.on('somethingElseHappens', cb) ;
    ch.once('hangup', () => {
        sendFailureNotification() ;
        cb() ;
    }) ;
}).sync(null) ;

mattdimeo avatar Jan 11 '19 16:01 mattdimeo