[Freeswitch-users] Lua session disappears after failed call, so hangup cause becomes inaccessable
Seven Du
dujinfang at gmail.com
Sun Apr 18 19:05:32 PDT 2010
the problem is that the session is not initialized
you could try disposition = new_session:getVariable("originate_disposition")
or see:
http://fisheye.freeswitch.org/browse/~raw,r=1cb080f85f63ac4f666397d64024b8561d62cb75/freeswitch-contrib/seven/lua/dialer.lua
2010/4/19 Bekele Martins <bekelemartins at gmail.com>:
> Has anybody else tried accessing hangup causes when placing a call in Lua?
>
> On Sun, Apr 18, 2010 at 3:37 AM, Bekele Martins <bekelemartins at gmail.com>
> wrote:
>>
>> Hi, I want my lua script to dial a phone number and return back the
>> disposition code (hangup cause). The problem is if the call fails, the
>> session variable is destroyed, and the call disposition code is destroyed as
>> well.
>> For example:
>> function make_call()
>> sessiondata = "sofia/gateway/myout/15555555555"
>> new_session = freeswitch.Session(sessiondata)
>> if (new_session:ready()) then
>> new_session:streamFile("hello.wav")
>> disposition = "ANSWERED"
>> else
>> disposition = new_session:getVariable("hangup_cause")
>> freeswitch.consoleLog("info","Hangup cause = " .. disposition .. "\n")
>> disposition = new_session:hangupCause()
>> freeswitch.consoleLog("info","Hangup cause = " .. disposition .. "\n")
>> end
>> return(disposition)
>> end
>> make_call()
>>
>> This returns the following errors:
>> 2010-04-18 03:29:58 [NOTICE] switch_channel.c:602
>> switch_channel_set_name() New Channel sofia/external/15555555555
>> [4bfbb177-2eee-422d-8f2a-5f9d71082254]
>> 2010-04-18 03:30:04 [NOTICE] sofia.c:3597 sofia_handle_sip_i_state()
>> Hangup sofia/external/15555555555 [CS_CONSUME_MEDIA] [NO_ROUTE_DESTINATION]
>> API CALL [lua(example.lua)] output:
>> -ERR encounterd
>> 2010-04-18 03:30:04 [ERR] freeswitch_lua.cpp:102 ready() session is not
>> initalized
>> 2010-04-18 03:30:04 [ERR] switch_cpp.cpp:600 getVariable() session is not
>> initalized
>> 2010-04-18 03:30:04 [INFO] switch_cpp.cpp:1122 console_log() Hangup cause
>> =
>> 2010-04-18 03:30:04 [ERR] mod_lua.cpp:182 lua_parse_and_execute()
>> /usr/local/freeswitch/scripts/example.lua:10: attempt to call method
>> 'hangupCause' (a nil value)
>> stack traceback:
>> /usr/local/freeswitch/scripts/example.lua:10: in function
>> 'make_call'
>> /usr/local/freeswitch/scripts/example.lua:16: in main chunk
>> 2010-04-18 03:30:04 [NOTICE] switch_core_session.c:1085
>> switch_core_session_thread() Session 1 (sofia/external/15555555555) Ended
>> 2010-04-18 03:30:04 [NOTICE] switch_core_session.c:1087
>> switch_core_session_thread() Close Channel sofia/external/15555555555
>> [CS_DESTROY]
>> Is there some way I can accomplish this?
>>
>
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
More information about the FreeSWITCH-users
mailing list