Originating a call from lua with rudimentary error checking
I have a lua script that originates a call: local s = freeswitch.Session ( "{ignore_early_media=true,origination_caller_id_name=" .. caller .. "}loopback/" .. destination .. "/default/XML") s:execute ("sleep", "1000") ... which works fine if a valid number is supplied. However if a invalid number is supplied, then the script hits: [ERR] switch_cpp.cpp:607 session is not initalized [ERR] freeswitch_lua.cpp:102 session is not initalized What's the recommended way to check if the session constructor was successful (i.e. the number could be dialed)? My other option is: local s = freeswitch.Session () local r = s:originate (nil, "{ignore_early_media=true,origination_caller_id_name=" .. caller .. "}loopback/" .. destination .. "/default/XML", 300) if r == 1 then stream:write ("-ERR call failed\n") return end which does handle invalid numbers however there are the minor issues such as: a) The documentation seems to strongly discourage using the originate method for some reason. b) The lua originate method seems to require timeout to be specified even though the documentation implies it's optional. c) Using this approach causes the message: [WARNING] mod_limit.c:576 USAGE: hash [insert|delete]/<realm>/<key>/<val> which I have yet to track down. Thoughts? -- John ------------------------------------------------------------------------- | Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com | | John Wehle | Fax: 1-215-540-5495 | | -------------------------------------------------------------------------
check that s is nil. /b On Jun 24, 2009, at 8:12 PM, John Wehle wrote:
What's the recommended way to check if the session constructor was successful (i.e. the number could be dialed)?
Brian West brian@freeswitch.org -- Meet us at ClueCon! http://www.cluecon.com
and that s.ready() is true On Thu, Jun 25, 2009 at 3:20 AM, Brian West <brian@freeswitch.org> wrote:
check that s is nil. /b
On Jun 24, 2009, at 8:12 PM, John Wehle wrote:
What's the recommended way to check if the session constructor was successful (i.e. the number could be dialed)?
Brian West brian@freeswitch.org
-- Meet us at ClueCon! http://www.cluecon.com
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
participants (3)
-
Anthony Minessale
-
Brian West
-
John Wehle