Use the eval API:<div><br></div><div>api = freeswitch.API()</div><div>my_uuid = session:getVariable('uuid')</div><div>...</div><div><br></div><div>state2 = api:executeString('eval uuid:' .. my_uuid .. ' ${Channel-Call-State}')</div>
<div>...</div><div><br></div><div><br></div><div>The 'eval' API is useful for getting those "magic" variables that show up when you do the info app or uuid_dump xxx.</div><div><br></div><div>-MC</div><div>
<div><br><div class="gmail_quote">On Wed, Jan 26, 2011 at 7:31 AM, Stephen Wilde <span dir="ltr"><<a href="mailto:wstephen80@gmail.com">wstephen80@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<div>I have difficult to check the state of an originated session in lua script.</div><div><br></div><div>I want to know when the originated session is ringing back or progressing or answered.</div><div><br></div><div>
I have tried with session:getState() but returns always CS_SOFT_EXECUTE.</div>
<div><br></div><div>My lua test script is called from dialplan with a:</div><div><br></div><div> <action application="lua" data="test1.lua"/></div><div><br></div><div><br></div><div>And the "test1.lua" script is:</div>
<div><br></div><div><div> session2 = freeswitch.Session("sofia/external/xxxxxx@a.b.c.d");</div><div><br></div><div> while (session:ready() and session2:ready()) do</div><div> state2 = session2:getVariable("channel_call_state");</div>
<div> freeswitch.consoleLog("warning", "State2 = " .. state2 .. "\n");</div><div> session:execute("sleep", "500");</div><div> end</div><div><br></div>
<div> if (session:ready()) then</div><div> session:hangup();</div><div> end</div><div><br></div><div> if (session2:ready()) then</div><div> session2:hangup();</div><div> end</div><div><br></div>
</div><div>This script fails because the session:getVariable("channel_call_state") returns nil.</div><div><br></div><div>What is the correct way to know the state of a call?</div><div><br></div><font color="#888888"><div>
Stephen</div>
</font><br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div></div>