Has anybody else tried accessing hangup causes when placing a call in Lua?<div><br><br><div class="gmail_quote">On Sun, Apr 18, 2010 at 3:37 AM, Bekele Martins <span dir="ltr">&lt;<a href="mailto:bekelemartins@gmail.com" target="_blank">bekelemartins@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<div>


<br></div><div>For example:</div><div><br></div><div><div><span style="background-color:rgb(255, 255, 51)">function make_call()</span></div><div><span style="background-color:rgb(255, 255, 51)">  sessiondata = &quot;sofia/gateway/myout/15555555555&quot;</span></div>


<div><span style="background-color:rgb(255, 255, 51)">  new_session = freeswitch.Session(sessiondata)</span></div><div><span style="background-color:rgb(255, 255, 51)">  if (new_session:ready()) then</span></div>
<div><span style="background-color:rgb(255, 255, 51)">    new_session:streamFile(&quot;hello.wav&quot;)</span></div><div><span style="background-color:rgb(255, 255, 51)">    disposition = &quot;ANSWERED&quot;</span></div>


<div><span style="background-color:rgb(255, 255, 51)">  else</span></div><div><span style="background-color:rgb(255, 255, 51)">    disposition = new_session:getVariable(&quot;hangup_cause&quot;)</span></div>
<div><span style="background-color:rgb(255, 255, 51)">    freeswitch.consoleLog(&quot;info&quot;,&quot;Hangup cause = &quot; .. disposition .. &quot;\n&quot;)</span></div><div><span style="background-color:rgb(255, 255, 51)">    disposition = new_session:hangupCause()</span></div>


<div><span style="background-color:rgb(255, 255, 51)">    freeswitch.consoleLog(&quot;info&quot;,&quot;Hangup cause = &quot; .. disposition .. &quot;\n&quot;)</span></div><div><span style="background-color:rgb(255, 255, 51)">  end</span></div>


<div><span style="background-color:rgb(255, 255, 51)">  return(disposition)</span></div><div><span style="background-color:rgb(255, 255, 51)">end</span></div><div><span style="background-color:rgb(255, 255, 51)">make_call()</span></div>


<div><br></div><div><br></div><div>This returns the following errors:</div><div><br></div><div><div><span style="background-color:rgb(255, 255, 51)">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]</span></div>


<div><span style="background-color:rgb(255, 255, 51)">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]</span></div>
<div><span style="background-color:rgb(255, 255, 51)">API CALL [lua(example.lua)] output:</span></div><div><span style="background-color:rgb(255, 255, 51)">-ERR encounterd</span></div>
<div><span style="background-color:rgb(255, 255, 51)"><br></span></div><div><span style="background-color:rgb(255, 255, 51)">2010-04-18 03:30:04 [ERR] freeswitch_lua.cpp:102 ready() session is not initalized</span></div>


<div><span style="background-color:rgb(255, 255, 51)">2010-04-18 03:30:04 [ERR] switch_cpp.cpp:600 getVariable() session is not initalized</span></div><div><span style="background-color:rgb(255, 255, 51)">2010-04-18 03:30:04 [INFO] switch_cpp.cpp:1122 console_log() Hangup cause =</span></div>


<div><span style="background-color:rgb(255, 255, 51)">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 &#39;hangupCause&#39; (a nil value)</span></div>


<div><span style="background-color:rgb(255, 255, 51)">stack traceback:</span></div><div><span style="background-color:rgb(255, 255, 51)">        /usr/local/freeswitch/scripts/example.lua:10: in function &#39;make_call&#39;</span></div>


<div><span style="background-color:rgb(255, 255, 51)">        /usr/local/freeswitch/scripts/example.lua:16: in main chunk</span></div><div><span style="background-color:rgb(255, 255, 51)">2010-04-18 03:30:04 [NOTICE] switch_core_session.c:1085 switch_core_session_thread() Session 1 (sofia/external/15555555555) Ended</span></div>


<div><span style="background-color:rgb(255, 255, 51)">2010-04-18 03:30:04 [NOTICE] switch_core_session.c:1087 switch_core_session_thread() Close Channel sofia/external/15555555555 [CS_DESTROY</span>]</div>
<div><br></div><div>Is there some way I can accomplish this?</div><div><br></div><div><br></div></div></div>
</blockquote></div><br>
</div>