The history of one project or how I created 7 years PBX based on Asterisk and Php

Surely many of you, like me, had an idea to make something unique. In this article I will describe the technical problems and solutions that had to be encountered in the development of automatic telephone exchanges. Perhaps this will help someone to decide on their idea, and someone to follow the beaten path, because I also used the experience of pioneers.


image


Idea and Key Requirements


Asterisk (framework ), FreePBX ( Asterisk). FreePBX – . , , .


. Asterisk , -, . , . , , FreePBX. FreePBX php4, php5.6  .


. FreePBX, , - .


:


  • , . ,
  • , ,
  • . FreePBX API , .. , , , API Asterisk,
  • opensource – .

, . , . , FreePBX , . , . .


, — . , , , , . , - , « » , .



. , , , , -.


image
, , Asterisk.


image


, :


  • , , ,
  • - ( ),
  • ,
  • , .

, :


......
class CPBX_MYIVR extends CPBX_IVR
{
 function __construct()
 {
 parent::__construct();
 $this->_module = "myivr";
 }
}
.....
$myIvrModule = new CPBX_MYIVR();
CPBXEngine::getInstance()->registerModule($myIvrModule,__DIR__); //  
CPBXEngine::getInstance()->registerModuleExtension($myIvrModule,'ivr',__DIR__); //  

. , , FreePBX. , . , .


API — , . , FreePBX, Apply .


:


image
* — (), .


API . -, Asterisk .
-, , .. .
-, .


, Askozia, , . .


.


Asterisk, . Asterisk , , REALTIME_HASH.


Asterisk Asterisk.


image


hints.


exten=>101,1,GoSub(‘sub-callusers’,s,1(1)); -  , /  ami

; sub-callusers –      .
[sub-callusers]
exten =>s,1,Noop()
exten =>s,n,Set(LOCAL(TOUSERID)=${ARG1})
exten =>s,n,ClearHash(TOUSERPARAM)
exten =>s,n,Set(HASH(TOUSERPARAM)=${REALTIME_HASH(rl_users,id,${LOCAL(TOUSERID)})})
exten =>s,n,GotoIf($["${HASH(TOUSERPARAM,id)}"=""]?return)
...

Ami ( Asterisk) .


API . , , “dialtime” ( , .. API Ami ).


. , . , , , . , -, API . , - « », .


. php Asterisk , Asterisk .


:


$usersInitSection = $dialplan->createExtSection('usersinit-sub','s');
$usersInitSection
 ->add('',new \Dialplan\ext_gotoif('$["${G_USERINIT}"="1"]','exit'))
 ->add('',new \Dialplan\ext_set('G_USERINIT','1'))
 ->add('',new \Dialplan\ext_gosub('1','s','sub-AddOnAnswerSub','usersconnected-sub'))
 ->add('',new \Dialplan\ext_gosub('1','s','sub-AddOnPredoDialSub','usersinitondial-sub'))
 ->add('',new \Dialplan\ext_set('LOCAL(TECH)','${CUT(CHANNEL(name),/,1)}'))
 ->add('',new \Dialplan\ext_gotoif('$["${LOCAL(TECH)}"="SIP"]','sipdev'))
 ->add('',new \Dialplan\ext_gotoif('$["${LOCAL(TECH)}"="PJSIP"]','pjsipdev'))

, . , .



Asterisk php, FastAGI php. FastAGI Asterisk, , . . Asterisk , php.


. , /. , 1,5 , , .


1 php Pthreads. - . php , - , php, php .


‘’, PHPLIB. php , , , – . FastAGI , php .


Asterisk 1,5 0,05 .


image


, , c php. -, php , -, -, – - php.


dialplanDynamicCall pbxCallRequest Asterisk.


image


( php xdebug ), .



. – . = : , , . , . .


:


  • , , .. ,
  • . FreePBX , , . , 0-1 . , ( . «», « »),
  • , , .

, .


:


( — ).


image


  1. « » 05:55:52 89295671458 89999999999, «2» 104. 60 36 .
  2. «2» 112 «1» 8 . 14 .
  3. «1» 13

, .


image


:


  1. « » 05:55:52 89295671458 89999999999.
  2. 05:55:53 «test»
  3. « », 16 . .
  4. « » () «1» 5 . .
  5. « » « ». ( ) 11 .
  6. « » «1, 2, 3» 11 . .
  7. . « 1». . 0 .
  8. « ». 31 , .
  9. «», 12 .
  10. 2 «1» «2» 12 «2». . «2», «2» «2».

. , . , , , , - , .


, . , , .


, , , , .


?


, – .


php, .. sip , , . Asterisk. ( - ) . Asterisk , - . , , , .


:


  • ,
  • -,
  • , ,
  • .

API. , , API . API , , . API .


(/), (, , , , ). – .


What will happen next will show time. There are many more nuances that are worth remaking, there are many more plans, but a year has already passed since the creation of the 3rd version and it can already be said that the idea works. The main minus of the 3rd version is the hardware resources, but for the convenience of development it is usually always the way to pay for it.


All Articles