From Mustard Partdridge, 6 Years ago, written in Plain Text.
- view diff
Embed
  1. console_log("notice", "*********** STARTING TO DIAL NUMBER! ***********\n");
  2.  
  3. //session.answer();
  4.  
  5. while (callTry()){};
  6.  
  7. function callTry(){
  8.     // Create new_session
  9.     new_session = new Session();
  10.      
  11.     console_log("notice", "*********** DIALING NUMBER! ***********\n");
  12.      
  13.     new_session.originate(session, "sofia/gateway/<gateway-name>/<number>");
  14.      
  15.     console_log("notice", "*********** CAUSE: " + new_session.cause + " ***********\n");
  16.      
  17.     if(new_session.cause == "USER_BUSY"){
  18.         console_log("notice", "*********** HANGING UP ***********\n");
  19.         //new_session.hangup();
  20.         console_log("notice", "*********** TRYING AGAIN ***********\n");
  21.         return true;
  22.     }
  23.      
  24.     // wait for it ... answer
  25.     new_session.waitForAnswer(10000);
  26.      
  27.     // IF everybody is ready, then bridge our current session & the new_session
  28.     if (new_session.ready()) {
  29.        bridge(session, new_session);
  30.     }
  31.     return false;
  32. }
  33. // log to the console
  34. console_log("notice", "*********** CALL CONNECTED! ***********\n");
  35.  
  36. // hangup when done
  37. new_session.hangup();