Skip to content

Commit

Permalink
Hangup cause
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasvargiu committed Nov 8, 2016
1 parent 31b052e commit 3f3f45a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PAMI/Message/Action/HangupAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ class HangupAction extends ActionMessage
* Constructor.
*
* @param string $channel Channel to hangup.
* @param int $cause Hangup cause.
*
* @return void
*/
public function __construct($channel)
public function __construct($channel, $cause = null)
{
parent::__construct('Hangup');
$this->setKey('Channel', $channel);

if (null !== $cause) {
$this->setKey('Cause', $cause);
}
}
}
15 changes: 15 additions & 0 deletions test/actions/Test_Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,21 @@ public function can_hangup()
$action = new \PAMI\Message\Action\HangupAction('channel');
$client = $this->_start($write, $action);
}
/**
* @test
*/
public function can_hangup_with_cause()
{
$write = array(implode("\r\n", array(
'action: Hangup',
'actionid: 1432.123',
'channel: channel',
'cause: 5',
''
)));
$action = new \PAMI\Message\Action\HangupAction('channel', 5);
$client = $this->_start($write, $action);
}
/**
* @test
*/
Expand Down

0 comments on commit 3f3f45a

Please sign in to comment.