Has anybody else tried accessing hangup causes when placing a call in Lua?
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()) thennew_session:streamFile("hello.wav")disposition = "ANSWERED"elsedisposition = new_session:getVariable("hangup_cause")freeswitch.consoleLog("info","Hangup cause = " .. disposition .. "\n")disposition = new_session:hangupCause()freeswitch.consoleLog("info","Hangup cause = " .. disposition .. "\n")endreturn(disposition)endmake_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 encounterd2010-04-18 03:30:04 [ERR] freeswitch_lua.cpp:102 ready() session is not initalized2010-04-18 03:30:04 [ERR] switch_cpp.cpp:600 getVariable() session is not initalized2010-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 chunk2010-04-18 03:30:04 [NOTICE] switch_core_session.c:1085 switch_core_session_thread() Session 1 (sofia/external/15555555555) Ended2010-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?