File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace gietos \AGI ;
44
5+ use Exception ;
6+
57/**
68 * PHP AGI Functions for Asterisk
79 * fork from https://github.com/d4rkstar/phpagi
@@ -681,13 +683,21 @@ public function verbose($message, $level = 1)
681683 *
682684 * @link http://www.voip-info.org/wiki-wait+for+digit
683685 * @param integer $timeout in millisecons. Use -1 for the timeout value if you want the call to wait indefinitely.
684- * @return array, see evaluate for return information. ['result'] is 0 if wait completes with no
685- * digit received, otherwise a decimal value of the DTMF tone. Use chr() to convert to
686- * ASCII.
686+ * @return int Digit received
687+ * @throws Exception
687688 */
688689 public function waitForDigit ($ timeout = -1 )
689690 {
690- return $ this ->evaluate ("WAIT FOR DIGIT $ timeout " );
691+ $ result = $ this ->evaluate ("WAIT FOR DIGIT $ timeout " );
692+ if ($ result ['code ' ] != '200 ' ) {
693+ throw new Exception ('Error while executing WAIT FOR DIGIT cmd ' );
694+ }
695+
696+ if ($ result ['result ' ] == '0 ' ) {
697+ return null ;
698+ }
699+
700+ return chr ($ result ['result ' ]);
691701 }
692702
693703 /**
You can’t perform that action at this time.
0 commit comments