Re: WebSocket Stasis Control Best Practice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






On Mon, Jun 16, 2014 at 11:21 AM, Maxim Litnitskiy <litnimaxster@xxxxxxxxx> wrote:
Matt!
Thank you so much for such a deep explanation.
But You still did not reveal your plans about accessing Asterisk builtin apps :-)
Once more example - a pause before playback.
In ARI you cannot use python time.sleep(1) as it blocks the whole async event loop.
How to tell a channel to wait?


Since you mention an async event loop, I'm going to assume you are using twisted - although ari-py does not use that. If, however, you are using twisted, I would just do something like the following:

def play_something(chan):
    chan.play(media='sound:tt-monkeys')

# Assume chan is a reference to my channel
reactor.callLater(1, play_something, chan)

If you aren't using twisted, you could use the threading.Timer module [1] to schedule a callback in a similar manner.

Or you can make Asterisk perform the pause:

chan.play(media='sound:silence/1')

Since ARI queues up sounds, that will automatically either (a) play 1 second of silence immediately, or (b) play 1 second of silence whenever the current media operation finishes.

--
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
_______________________________________________
asterisk-app-dev mailing list
asterisk-app-dev@xxxxxxxxxxxxxxxx
http://lists.digium.com/cgi-bin/mailman/listinfo/asterisk-app-dev

[Index of Archives]     [Asterisk SS7]     [Asterisk Announcements]     [Asterisk Users]     [PJ SIP]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Linux API]

  Powered by Linux