[Freeswitch-users] Re- End Lua script after HangupHook handled without all the extra code to handle the return to the function

Michael Collins msc at freeswitch.org
Sat Mar 5 00:11:04 MSK 2016


On Fri, Mar 4, 2016 at 9:19 AM, Abaci B <abaci64 at gmail.com> wrote:

> The question is not how to figure out when to exit the lua script, the
> question is *how to exit the lua script*, and that can sometimes be
> tricky or complicated as return "exit" only works from hangup hook.
>

Are you positive that it works only from a hangup hook? It seems to work at
the end of any loop:

-- testing exit (no session, call with luarun)
freeswitch.consoleLog('INFO',"Starting infinite loop...\n")
while(1) do
  freeswitch.consoleLog('WARNING',"Before exit...\n")
  return "exit"
end
freeswitch.consoleLog('INFO',"All done!\n")


Or with a session:
-- test exit with session, no hangup hook
session:answer()
freeswitch.consoleLog('INFO',"Entering main loop...\n")
while ( session:ready() == true ) do
  freeswitch.consoleLog('WARNING',"Inside loop...\n")
  return "exit"
end
freeswitch.consoleLog('INFO',"All done!\n")

In both cases I never see "All done!" at the CLI. Can you try it and see if
there's a scenario where it does not exit as expected?

-MC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160304/c9f330c1/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list