From b74b5a77d3e2e450fe15afc28be81e4efe79ff41 Mon Sep 17 00:00:00 2001 From: Matt DiMeo Date: Fri, 11 Jan 2019 08:33:01 -0800 Subject: [PATCH] channel emits 'hangup' event on hangup --- README.md | 5 +++++ lib/agi-channel.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 8addc06..fbc6c4a 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,11 @@ Plays the specified `file`. Playback can be stopped using one of the (optional) Hangs up the current channel. +#### 2.3 Channel events + +* 'hangup' + +Emitted when the current channel is hung up. ## LICENSE diff --git a/lib/agi-channel.js b/lib/agi-channel.js index 91fc74b..d3f217a 100644 --- a/lib/agi-channel.js +++ b/lib/agi-channel.js @@ -81,6 +81,9 @@ var AGIChannel = function(request, mapper) { util.inherits(AGIChannel, events.EventEmitter); AGIChannel.prototype.handleReply = function(reply) { + if (reply == 'hangup') { + this.emit('hangup') ; + } if (this.callback) { if (reply == 'hangup') { this.callback('hangup');