i want to originate 5 calls after one second sleep using lua and get the response using playandgetdigits(), but scipt originate call one by one. please guide me how i can call 5 numbers at the same time, here is my code =============================================================================================================================== *-- TestCall.lua* function PlayMessageAndGetResponse(message) count = 1 invalid = 'say:flite:slt:nvalid input , please enter again' audio_for_prompt = 'say:flite:slt:press 1 for YES, Press 2 for No, Press 3 for Record Message and Press 4 for Replay' while session:ready() == true and count <= 3 do session:sleep(250) session:streamFile(message) session:sleep(250) digits = session:playAndGetDigits(1, 1, 3, 5, "#", audio_for_prompt, invalid, "^(1|2|3|4)$") if digits == "" then return 0 elseif digits == "4" then count = count + 1 else return digits end end return 0 end number = argv[1] message= argv[2] greeting = "Welcome! You have a Mesage" bye_message = "Bye bye." response = 0 freeswitch.consoleLog("info", "The Number "..number..", message "..message.."\n") session = freeswitch.Session("{ignore_early_media=true,origination_caller_id_number=321}user/"..number.."") session:setAutoHangup(false) session:set_tts_parms("flite", "slt") dispoA = "None" while(session:ready() and dispoA ~= "ANSWER") do dispoA = session:getVariable("endpoint_disposition") freeswitch.consoleLog("INFO","Leg A disposition is '" .. dispoA .. "'\n") os.execute("sleep 1") end -- legA while if session:ready() == true and dispoA == "ANSWER" then uuid = session:getVariable("uuid") session:speak(greeting) response = PlayMessageAndGetResponse(message) session:speak(bye_message) session:hangup() end cause = session:hangupCause() session:destroy() freeswitch.consoleLog('info',"Number "..number..", respond "..response.." hangup cause is "..cause.."\n") =============================================================================================================================== *-- campaign.lua* count = 1000 number = {} for i = 1, 5 do number[i] = count count = count + 1 end for i = 1, 5 do freeswitch.consoleLog("warning", "Calling " ..number[i].. "\n") api = freeswitch.API(); reply = api:executeString("luarun TestCall.lua "..number[i].." ".."test_msg.wav") os.execute("sleep 1") end =============================================================================================================================== Regards Shahzad Bhatti
On Thu, Jun 28, 2012 at 7:40 AM, Shahzad Bhatti <shahzad.bhatti@g-r-v.com>wrote:
i want to originate 5 calls after one second sleep using lua and get the response using playandgetdigits(), but scipt originate call one by one.
please guide me how i can call 5 numbers at the same time,
Short answer: you can't. Each Lua instance corresponds to a single session/channel. Can't have more than one when doing it like this. If you need to control multiple channels then you really, really need to be using the event socket, and ESL in particular. I recommend chapter 9 of the original FS book and chapter 4 of the FS cookbook. There are also lots of examples in the source tree, in freeswitch-contrib, and on the wiki. -MC
participants (2)
-
Michael Collins
-
Shahzad Bhatti