[Freeswitch-users] Originating a call from lua with rudimentary error checking
John Wehle
john at feith.com
Thu Jun 25 12:35:55 PDT 2009
>> What's the recommended way to check if the session constructor was
>> successful (i.e. the number could be dialed)?
> check that s is nil.
Doesn't work ... s is never nil. Type shows it as userdata
even if Session failed. Specifically my test was:
local s = freeswitch.Session (
"{ignore_early_media=true,origination_caller_id_name=" ..
caller .. "}loopback/" .. destination .. "/default/XML")
stream:write (type(s))
if s == nil then
stream:write ("-ERR call failed\n")
return
end
and I dialed an unreachable number.
> and that s.ready() is true
Checking s.ready() results in:
[ERR] freeswitch_lua.cpp:102 session is not initalized
if Session failed.
What I'm looking for is a way to try to originate a call which doesn't
throw ERR messages if the attempt fails.
Explicitly calling session.originate seems to allow you to check if
the call was successful ... is there a particular reason it's discouraged?
I'm happy to avoid it if a better approach is available, however I'm
having trouble finding one.
-- John
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john at feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------
More information about the FreeSWITCH-users
mailing list