[Freeswitch-users] freeswitch.EventConsumer, can be utilized event-based

Michael Jerris mike at jerris.com
Tue Mar 31 08:32:23 PDT 2009


as replied earlier, if your doing nothing but consuming events, you  
can just block instead of sleep:

con:pop(1)

there is also a msleep function that you can call the same way you do  
console_log, it takes milli seconds as its arg.  Note this should NOT  
be used when you have a script running as a session, only when you are  
running an api script.

Mike

On Mar 31, 2009, at 11:15 AM, Matthew Fong wrote:

> Got a few more questions about running LUA scripts, please forgive  
> me, I'm an absolute newbie with LUA.
>
> If I want to subscribe to a custom event, and I use
>
> con = freeswitch.EventConsumer("CUSTOM my::event");
>
> I get an error. Is this because I must subscribe to the CUSTOM  
> (only) event, and then filter out the events using the Event- 
> Subclass myself? Or am I missing something in the syntax of the  
> subscribe?
>
> Also, if I do not have a freeswitch.Session, what is the best way to  
> have my LUA script sleep? I want a functionality, where a statement  
> inside my LUA script gets iterated every 30 seconds. My program does  
> not use a session, so I cannot use session:execute("sleep","1000"),  
> as suggested in the wiki. I tried api::sleep(30000) and a few other  
> combinations with execute but no luck :(.
>
> Thanks.
> --matt
>
> On Sat, Mar 28, 2009 at 12:43 AM, Michael Collins  
> <msc at freeswitch.org> wrote:
> > con = freeswitch.EventConsumer("all");
> >
> > now you have a consumer obj
> >
> > every time you call con:pop() with no arg you will either get an  
> event or
> > nil when there are no events to consume.
> > every time you call con:pop(1) the consumer object will block  
> until there is
> > an event.
> >
> > So you use the first way in conjunction with some other lock to do  
> async or
> > the 2nd way you do a dedicated blocking loop.
>
> FYI, I added this information to the wiki page for  
> freeswitch.EventConsumer.
> -MC
>
> _______________________________________________
> 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/20090331/726287a1/attachment-0002.html 


More information about the FreeSWITCH-users mailing list