[Freeswitch-users] Re - FreeSWITCH Lua CUSTOM events interrupting session:streamFile playback - is this possible?

Andrew Keil andrew.keil at visytel.com
Thu Dec 11 07:11:15 MSK 2014


Seven Du,

Thanks for your response.  I eventually found a way by sending via the Event Socket Layer:

sendmsg <channel uuid>
call-command: execute
execute-app-name: break

Then sending the CUSTOM message and using the con:pop(1,5000) approach to pop the CUSTOM message of the event queue.

This approach solves the problem, although I wish I could send an event via ESL that will trigger the setInputCallback(…) function.  However I have not found a way to do that as yet.

Andrew

From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Seven Du
Sent: Tuesday, 9 December 2014 10:16 AM
To: FreeSWITCH Users Help
Subject: Re: [Freeswitch-users] Re - FreeSWITCH Lua CUSTOM events interrupting session:streamFile playback - is this possible?

I believe the playback_terminitors chan var works, or you could try set an input callback and return “break” when dtmf detected.

--
Seven Du
http://about.me/dujinfang
http://www.dujinfang.com
http://www.freeswitch.org.cn

Sent with Sparrow<http://www.sparrowmailapp.com/?sig>


On Tuesday, December 9, 2014 at 7:00 AM, Andrew Keil wrote:

To FreeSWITCH users,



After progressing with Lua inside FreeSWITCH I have a question that I cannot source an answer for within the current FreeSWITCH documentation.



I have a requirement for an external application to process an event (via the event socket layer) then return the results back to the application while an audio file is played back in a loop to the caller.



From the current documentation this method allows for the event to be sent then the return event is “consumed” using a polling approach.  However the caller is listening to silence.



function poll()

    -- create event and listener

    local event = freeswitch.Event("CUSTOM", "ping::running?")

    local con = freeswitch.EventConsumer("CUSTOM", "ping::running!")



    -- add text ad libitum

    event:addHeader("hi", "there")

    -- fire event

    event:fire()

    -- and wait for reply but not very long

                local retevent = con:pop(1, 5000)

    if retevent then

        print("reply received")

                                freeswitch.consoleLog("DEBUG",  string.format("reply received: %s\n",retevent:getHeader("Result")))

        return true

    end

    print("no reply")

                freeswitch.consoleLog("DEBUG", "no reply\n")

    return false

end



Some questions:

Is there a way to playback audio (eg. session:streamFile(…)) while this takes place, since currently session:streamFile(…) seems to be a blocking function (ie. Finishes when the audio file is played back completely)?

Is there a way to use session:setInputCallback(…) to handle an external CUSTOM event being returned (since this would then be able to interrupt the session:streamFile(…) just like it does for DTMF or speech recognition)?



If you have a preferred approach to solving this then I am open to your suggestions.



I appreciate any assistance that you can give.



Kind Regards,



Andrew Keil


_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting at freeswitch.org<mailto:consulting at freeswitch.org>
http://www.freeswitchsolutions.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org<mailto: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/20141211/7ef0658b/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list