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><div>Stephen</div>