Exemplo n.º 1
0
 function OnDTMF($tone)
 {
     switch ($tone) {
         case "*":
             // hang up the IVR channel and possibly the incoming call
             IVR::Hangup();
             break;
         case "#":
             // return to calling IVR with value 'Got #'
             IVR::Leave("Got {$tone}");
             break;
         case "0":
         case "1":
         case "2":
             $this->Output("Got {$tone}");
             break;
         default:
             return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Try and if found execute a table described operation - internal use
  * @param $state State to match
  * @param $text Event name of DTMF
  * @return True if handled
  */
 private function TryTable($state, $text)
 {
     if (isset($this->optable["{$state}:{$text}"])) {
         $op = explode(":", $this->optable["{$state}:{$text}"]);
         $this->Debug("Found table operation '" . $op[0] . "'");
         switch ($op[0]) {
             case "output":
                 // Output a text to console or log file
                 $this->Output($op[1]);
                 break;
             case "debug":
                 // Output a text if debugging is enabled
                 $this->Debug($op[1]);
                 break;
             case "state":
                 // Change local IVR state
                 $this->SetState($op[1]);
                 break;
             case "play":
                 // Play one or many sound files
                 array_shift($op);
                 $this->PlayFile($op);
                 break;
             case "play_recstop":
                 array_shift($op);
                 $this->PlayRecStop($op);
                 break;
             case "recstop":
                 $this->RecStop($op[1]);
                 break;
             case "tone":
                 // Start playing a tone
                 $this->PlayTone($op[1]);
                 break;
             case "stop":
                 // Stop sound playback
                 $this->PlayStop();
                 break;
             case "dtmf":
                 // Emit a DTMF sequence
                 $this->PlayDTMF($op[1], isset($op[2]) ? $op[2] : null);
                 break;
             case "jump":
                 // Jump to another IVR, leave this one
                 IVR::Jump($op[1], isset($op[2]) ? $op[2] : null);
                 break;
             case "call":
                 // Call into another IVR, put this on stack
                 IVR::Call($op[1], isset($op[2]) ? $op[2] : null);
                 break;
             case "leave":
                 // Leave this IVR, return to one on stack
                 IVR::Leave(isset($op[1]) ? $op[1] : null);
                 break;
             case "progress":
                 // Emit a call progress notification
             // Emit a call progress notification
             case "ringing":
                 // Emit a call ringing notification
             // Emit a call ringing notification
             case "answered":
                 // Emit an answer notification
                 $m = new Yate("call." . $op[0]);
                 $m->id = "";
                 $m->SetParam("id", IVR::ChannelID());
                 $m->SetParam("targetid", IVR::TargetID());
                 $m->SetParam("cdrcreate", false);
                 $m->Dispatch();
                 break;
             case "hangup":
                 // Hangup the entire IVR
                 IVR::Hangup();
                 break;
             default:
                 $this->Output("Invalid table operation '" . $op[0] . "'");
                 return false;
         }
         return true;
     }
     return false;
 }