View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}


[Emanuele Deserti|]

1.2 - 21 February 2008: Second draft
1.1 - 10 October 2007: First draft

Zend_Asterisk is a component that contain two main components: Zend_Asterisk_Manager and Zend_Asterisk_Agi
Zend_Asterisk_Manager will connect with the Asterisk Manager interfaces and can send and load data with the local Asterisk server.
Zend_Asterisk_Agi implements a Asterisk Gateway Interface which can be used to control and interact with a call in progress.

* [Download current release|]
* [Asterisk (Digium)|]
* [|]

* This component *will* connect with the Asterisk Manager and can write and read to Asterisk socket.
* This component *will* answer to Asterisk call and hangup an active call.
* This component *will* detect DTMF digits (single or collect digits) and play specific audio files.
* This component *will* read and write Asterisk global variables (like extensions) and call variables (like callerid).

* Zend_Exception

The component can be used in two way:
- As Asterisk Manager, who can send command directly to the server and read it's output
- As Asterisk Gateway Interfaces, who can answer to a call, process user input, interact with others services (like a database) and return results or informations to user.

* Milestone 1: [design notes will be published here|]
* Milestone 2: Asterisk Gateway Interface: write to socket and read from socket.
* Milestone 3: Asterisk Gateway Interface: parse callerid, collect digits, play audio files.
* Milestone 4: Asterisk Manager: connect to Asterisk Server, send commands and read outputs.

* Zend_Asterisk_Exception
* Zend_Asterisk (factory class)
* Zend_Asterisk_Manager
* Zend_Asterisk_Agi

||MANAGER:send command and read output||


$configs = array('server' => 'localhost',
'post' => '5038',
'username' => 'manageruser',
'secret' => 'managerpass'

$asm = new Zend_Asterisk_Manager($configs);
if ($asm->connect()) {
$result = $asm->listCommands();

$result = $asm->command("sip show peers");

$result = $asm->command("core show version");


||MANAGER:originate dial||

// If the user click on "Dial" link (route is like /module/controller/action/dial/301)
if ($this->_hasParam('dial')) {
$source = '201'; // The source peer/number, I take this from the Auth session
$destination = $this->_getParam('dial') // The destination peer/number, I take this from a GET param

// Connect to Asterisk Manager
if ($asm->connect()) {
// Originate: Channel, Extensions, Context, Priority and Caller ID
$asm->Originate('SIP/' . $source, $destination, 'internal', '1', null, null, null, '"Caller ID" <'.$source.'>');

class Zend_Magic_Exception extends Zend_Exception {}

class Zend_Asterisk_Manager {}

class Zend_Asterisk_Agi

function answer() {}
function hangup() {}
function getDigits() {}