From Timothy , 4 Years ago, written in Lua.
- view diff
Embed
  1. con = freeswitch.EventConsumer("all"); --enabled EventConsumer
  2.  
  3.  
  4. service_type= session:getVariable("service_type") or "";
  5. callee_id= string.sub(session:getVariable("caller_id_number"),5,-1) or "";
  6. caller_id= string.sub(session:getVariable("ANI"),5,-1) or "";
  7. uuid= session:getVariable("uuid") or "";
  8. session:setVariable("ObCause", "");
  9. --[[
  10. freeswitch.consoleLog("info","service Name="..service_type.."\n")
  11. freeswitch.consoleLog("info","uuid="..uuid.."\n")
  12. freeswitch.consoleLog("info","caller ID="..caller_id.."\n")
  13. freeswitch.consoleLog("info","callee ID="..callee_id.."\n")
  14.  
  15. --]]
  16.  
  17. while (session:ready()) do
  18. session:setAutoHangup(false)    
  19.  
  20.  
  21.  
  22.          for e in (function() return con:pop(1,500) end) do
  23.                 event_name = e:getHeader("Event-Name") or ""
  24.          if (event_name == "CHANNEL_ANSWER") then
  25.                 session:sleep(1000);
  26.                 session:execute("avmd_start");
  27.                         session:sleep(30000);
  28.  
  29.                 --digits = session:read(1, 1, Obprompt, 3000, "#");
  30.                         session:execute("avmd_stop");
  31.                         session:hangup();
  32.                         session:destroy();
  33.  
  34.                 end
  35.         end
  36.  
  37. end
  38.  
  39.