[Freeswitch-users] How to check call state in lua script?

Stephen Wilde wstephen80 at gmail.com
Thu Jan 27 13:11:50 MSK 2011


Thank you Michael, it works!

Stephen

On Thu, Jan 27, 2011 at 2:05 AM, Michael Collins <msc at freeswitch.org> wrote:

> Use the eval API:
>
> api = freeswitch.API()
> my_uuid = session:getVariable('uuid')
> ...
>
> state2 = api:executeString('eval uuid:' .. my_uuid .. '
> ${Channel-Call-State}')
> ...
>
>
> The 'eval' API is useful for getting those "magic" variables that show up
> when you do the info app or uuid_dump xxx.
>
> -MC
>
> On Wed, Jan 26, 2011 at 7:31 AM, Stephen Wilde <wstephen80 at gmail.com>wrote:
>
>> Hi,
>> I have difficult to check the state of an originated session in lua
>> script.
>>
>> I want to know when the originated session is ringing back or progressing
>> or answered.
>>
>> I have tried with session:getState() but returns always CS_SOFT_EXECUTE.
>>
>> My lua test script is called from dialplan with a:
>>
>>         <action application="lua" data="test1.lua"/>
>>
>>
>> And the "test1.lua" script is:
>>
>>     session2 = freeswitch.Session("sofia/external/xxxxxx at a.b.c.d");
>>
>>     while (session:ready() and session2:ready()) do
>>           state2 = session2:getVariable("channel_call_state");
>>           freeswitch.consoleLog("warning", "State2 = " .. state2 .. "\n");
>>           session:execute("sleep", "500");
>>     end
>>
>>     if (session:ready()) then
>>           session:hangup();
>>     end
>>
>>     if (session2:ready()) then
>>           session2:hangup();
>>     end
>>
>> This script fails because the session:getVariable("channel_call_state")
>> returns nil.
>>
>> What is the correct way to know the state of a call?
>>
>> Stephen
>>
>> _______________________________________________
>> 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
>>
>>
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110127/77af2186/attachment.html 


More information about the FreeSWITCH-users mailing list