[Freeswitch-users] Trouble Getting session:getVariable("state") in Lua

Anthony Minessale anthony.minessale at gmail.com
Sat Sep 19 09:47:12 PDT 2009


you should always check session:ready() in all loops
if session:ready() fails it means you must exit your script because the call
has either been transferred or hungup.


On Sat, Sep 19, 2009 at 11:41 AM, Matt Hunter <matt at hellohunter.com> wrote:

> I think this is probably also the problem that this user on Jira thought
> was a bug at
> http://jira.freeswitch.org/browse/MODLANG-128
>
>  <http://jira.freeswitch.org/browse/MODLANG-128>Anyway, thanks!
>
> I had wanted the state of the channel because after hang-up of a channel
> being controlled by a lua script, the script continues executing. My lua
> script has a few loops, so if a caller hangups during a loop, the lua script
> never exits (gets caught in the loop). So I was trying to get the state
> variable to see if the call still exists, and if not exist the loop and
> close the lua script.
>
> Is there an easier way that I'm missing to accomplish this?
>
> Also when using onInput and a dtmf_callback within a luascript, you can
> interrupt a session:sleep and/or a playmsg, but it seems once the onInput
> execution is finished, the sleep and playmsg continue. Is the correct method
> to have the onInput return break; to stop the old sleep and playmsg from
> Q'ing?
>
> Thanks so much.
>
> --matt
>
>
> On Sat, Sep 19, 2009 at 10:27 PM, Anthony Minessale <
> anthony.minessale at gmail.com> wrote:
>
>> state is not a variable.
>> I added a session:getState() for you to trunk but I am not sure why you
>> need it.
>>
>>
>> On Sat, Sep 19, 2009 at 9:36 AM, Matthew Fong <mattdfong at gmail.com>wrote:
>>
>>> I'm having trouble getting the channel variable state in my Lua ivr
>>> example.
>>> I have tried both
>>>
>>> session:getVariable("state")
>>> session:getVariable("Channel-State")
>>> session:getVariable("answer_state")
>>> session:getVariable("Answer-State")
>>>
>>> but lua reports nil for all attempts
>>>
>>> I did a uuid_dump and it appears normal....and both Channel-State and
>>> Answer-State Variables are present...does anyone know why my Lua IVR can not
>>> get these channel variables? Thanks
>>>
>>> --matt
>>>
>>> uuid_dump:Event-Name: CHANNEL_DATA
>>> Core-UUID: ed5556a8-060f-4ce4-85bb-0a70b08120cf
>>> FreeSWITCH-Hostname: matthew-laptop
>>> FreeSWITCH-IPv4: 192.168.2.2
>>> FreeSWITCH-IPv6: %3A%3A1
>>> Event-Date-Local: 2009-09-19%2012%3A47%3A20
>>> Event-Date-GMT: Sat,%2019%20Sep%202009%2012%3A47%3A20%20GMT
>>> Event-Date-Timestamp: 1253364440904749
>>> Event-Calling-File: mod_commands.c
>>> Event-Calling-Function: uuid_dump_function
>>> Event-Calling-Line-Number: 3298
>>> Channel-State: CS_EXECUTE
>>> Channel-State-Number: 4
>>> Channel-Name: sofia/internal/1001
>>> Unique-ID: 12ee98af-d76d-483c-b9a9-59e7f08ca4e9
>>> Call-Direction: outbound
>>> Presence-Call-Direction: outbound
>>> Answer-State: answered
>>> Channel-Read-Codec-Name: PCMU
>>> Channel-Read-Codec-Rate: 8000
>>> Channel-Write-Codec-Name: PCMU
>>> Channel-Write-Codec-Rate: 8000
>>> Caller-Caller-ID-Name: FreeSWITCH
>>> Caller-Caller-ID-Number: 0000000000
>>> Caller-Network-Addr: 192.168.2.4
>>> Caller-Destination-Number: 1001
>>> Caller-Unique-ID: 12ee98af-d76d-483c-b9a9-59e7f08ca4e9
>>> Caller-Source: src/switch_ivr_originate.c
>>> Caller-Context: default
>>> Caller-Channel-Name: sofia/internal/1001
>>> Caller-Profile-Index: 1
>>> Caller-Profile-Created-Time: 1253364439936068
>>> Caller-Channel-Created-Time: 1253364439936068
>>> Caller-Channel-Answered-Time: 1253364440900612
>>> Caller-Channel-Progress-Time: 1253364439976071
>>> Caller-Channel-Progress-Media-Time: 0
>>> Caller-Channel-Hangup-Time: 0
>>> Caller-Channel-Transfer-Time: 0
>>> Caller-Screen-Bit: true
>>> Caller-Privacy-Hide-Name: false
>>> Caller-Privacy-Hide-Number: false
>>> variable_channel_name: sofia/internal/1001
>>> variable_sip_local_url: 1001%40192.168.2.2
>>> variable_sip_destination_url:
>>> %22user%22%20%3Csip%3A1001%40192.168.2.4%3A5061%3Bfs_nat%3Dyes%3Bfs_path%3Dsip%253A1001%2540192.168.2.4%253A5061%3E
>>> variable_is_outbound: true
>>> variable_ignore_early_media: true
>>> variable_originate_early_media: false
>>> variable_sip_nat_detected: true
>>> variable_sofia_profile_name: internal
>>> variable_sip_call_id: 690ad846-1fbd-122d-1599-0010c6ceb785
>>> variable_sip_reply_host: 192.168.2.4
>>> variable_sip_reply_port: 5061
>>> variable_sip_user_agent: Linksys/PAP2T-5.1.6(LS)
>>> variable_switch_r_sdp:
>>> v%3D0%0D%0Ao%3D-%201231630%201231630%20IN%20IP4%20192.168.2.4%0D%0As%3D-%0D%0Ac%3DIN%20IP4%20192.168.2.4%0D%0At%3D0%200%0D%0Am%3Daudio%2016406%20RTP/AVP%200%20100%20101%0D%0Aa%3Drtpmap%3A0%20PCMU/8000%0D%0Aa%3Drtpmap%3A100%20NSE/8000%0D%0Aa%3Dfmtp%3A100%20192-193%0D%0Aa%3Drtpmap%3A101%20telephone-event/8000%0D%0Aa%3Dfmtp%3A101%200-15%0D%0Aa%3Dptime%3A20%0D%0A
>>> variable_remote_media_ip: 192.168.2.4
>>> variable_remote_media_port: 16406
>>> variable_read_codec: PCMU
>>> variable_read_rate: 8000
>>> variable_write_codec: PCMU
>>> variable_write_rate: 8000
>>> variable_local_media_ip: 192.168.2.2
>>> variable_local_media_port: 20442
>>> variable_endpoint_disposition: ANSWER
>>> variable_current_application_data: api_epik_pocket.lua
>>> variable_current_application: lua
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>>
>> --
>> Anthony Minessale II
>>
>> FreeSWITCH http://www.freeswitch.org/
>> ClueCon http://www.cluecon.com/
>> Twitter: http://twitter.com/FreeSWITCH_wire
>>
>> AIM: anthm
>> MSN:anthony_minessale at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
>> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
>> IRC: irc.freenode.net #freeswitch
>>
>> FreeSWITCH Developer Conference
>> sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
>> iax:guest at conference.freeswitch.org/888
>> googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
>> pstn:213-799-1400
>>
>> _______________________________________________
>> 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
>
>


-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
iax:guest at conference.freeswitch.org/888
googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
pstn:213-799-1400
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20090919/2a4b1bd8/attachment-0002.html 


More information about the FreeSWITCH-users mailing list