From Colossal Wigeon, 9 Months ago, written in PHP.
  1. #!/usr/bin/php -q
  2. <?php
  3.  
  4. set_include_path('/usr/local/share/yate/scripts'. PATH_SEPARATOR . '/home/library'. PATH_SEPARATOR . get_include_path());
  5.  
  6. define('ERROR_LOG_FILE', '/home/scripts/logs/routing.log.'.date('Y-m'));
  7. ini_set('error_log', ERROR_LOG_FILE);
  8.  
  9. require_once("logit.php");
  10. require_once("libyate.php");
  11.  
  12. /* Always the first action to do */
  13. Yate::Init();
  14. Yate::Debug(true);
  15. /* Comment the next line to get output only in logs, not in rmanager */
  16. Yate::Output(true);
  17.  
  18. $ourcallid = "dialout/" . uniqid(rand(),1);
  19. /* Set tracking name for all installed handlers */
  20. Yate::SetLocal("trackparam","routing.php");
  21. /* Install a handler for the call routing message */
  22. Yate::Install("call.route",80);
  23. // Yate::Install("call.execute",80);
  24.  
  25. for (;;) {
  26.     $ev=Yate::GetEvent();
  27.  
  28.     logit($ev);
  29.  
  30.     /* If Yate disconnected us then exit cleanly */
  31.     if ($ev === false)
  32.         break;
  33.     /* Empty events are normal in non-blocking operation.
  34.        This is an opportunity to do idle tasks and check timers */
  35.     if ($ev === true) {
  36. //        Yate::Output("PHP event: empty");
  37.         continue;
  38.     }
  39.     /* If we reached here we should have a valid object */
  40.     switch ($ev->type) {
  41.         case "incoming":
  42.  
  43.         switch ($ev->name) {
  44.                 case "call.execute":
  45.  
  46.                 $caller = $ev->GetValue("caller");
  47.                     $callername = $ev->GetValue("callername");
  48.                     $called = $ev->GetValue("called");
  49.                 $partycallid = $ev->GetValue("id");
  50.  
  51.                 $ev->params["targetid"] = $ourcallid;
  52.                 $ev->handled = true;
  53.  
  54.                 $m = new Yate("call.execute");
  55.                 $m->SetParam("id",$ourcallid);
  56.                 $m->SetParam("trunk",'bite');
  57.                 $m->SetParam("callto",'sig/BC40'.$called.'.');
  58.                 $m->SetParam("caller",$caller);
  59.                 $m->SetParam("callername",$callername);
  60.                 $m->SetParam("called",$called);
  61.                 $m->Dispatch();
  62.  
  63.                     break;
  64.                 case "call.answered":
  65.                     // callAnswered();
  66.                     $ev->handled = true;
  67.                     break;
  68.                 case "chan.notify":
  69.                     // callFailed("noanswer");
  70.                     $ev->handled = true;
  71.                     break;
  72.                 case "chan.dtmf":
  73.                     // gotDTMF($ev->GetValue("text"));
  74.                     $ev->handled = true;
  75.                     break;
  76.                 case "chan.disconnected":
  77.                     // callFailed($ev->GetValue("reason"));
  78.                     /* Put it back running to avoid double destruction... */
  79.                     // $running = true;
  80.                     $ev->handled = true;
  81.                     break;
  82.         }
  83.  
  84.         $ev->Acknowledge();
  85.  
  86.             break;
  87.         case "answer":
  88.             Yate::Output("PHP Answered: " . $ev->name . " id: " . $ev->id);
  89.             break;
  90.         case "installed":
  91.             Yate::Output("PHP Installed: " . $ev->name);
  92.             break;
  93.         case "uninstalled":
  94.             Yate::Output("PHP Uninstalled: " . $ev->name);
  95.             break;
  96.         default:
  97.             Yate::Output("PHP Event: " . $ev->type);
  98.     }
  99. }
  100.  
  101. Yate::Output("PHP: bye!");
  102. ?>
  103.  

Replies to yate call.execute rss

Title Name Language When
Re: yate call.execute Obese Goat php 9 Months ago.
captcha