Yeah, probably just using con.pop(1) - that waits for an event to be caught, instead than con.pop(0), thus avoiding "sleeps" would do the trick<br><br><div class="gmail_quote">On Tue, Sep 8, 2009 at 20:12, Phillip Jones <span dir="ltr"><<a href="mailto:pjintheusa@gmail.com">pjintheusa@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">What is:<br>
<br>
<font face="courier new,monospace">freeswitch.msleep(100);<br>
<br>
Why aren't you using Thread.Sleep?</font><div><div></div><div class="h5"><br><br><div class="gmail_quote">On Tue, Sep 8, 2009 at 2:21 AM, Josh Rivers <span dir="ltr"><<a href="mailto:josh@radianttiger.com" target="_blank">josh@radianttiger.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">Thanks for the response!<div><br></div><div>I have tried putting a long-running loop here, but then it blocks anything else managed from happening:</div>
<div><br></div><div><div> public class TestLoop : ILoadNotificationPlugin</div>
<div> {</div><div> public bool Load()</div><div><div> {</div><div> EventConsumer con = new EventConsumer("all", "");</div></div><div> while (true)</div>
<div><div> {</div>
<div> Event ev = con.pop(0);</div></div><div> Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);</div><div> freeswitch.msleep(100);</div><div> }</div>
<div> }</div><div> }</div><div><br></div><div>However, if I fork off a thread here, freeswitch crashes:</div><div><div> public class TestLoop : ILoadNotificationPlugin</div><div> {</div><div> public bool Load()</div>
<div> {</div><div> ThreadPool.QueueUserWorkItem((o) =></div><div> {</div><div> Log.WriteLine(LogLevel.Notice, "Thread Starting. ");</div><div><div> EventConsumer con = new EventConsumer("all", "");</div>
</div><div> while (true)</div><div><div> {</div><div> Event ev = con.pop(0);</div></div><div> Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);</div>
<div> freeswitch.msleep(100);</div><div> }</div><div> });</div><div> return true;</div><div> }</div><div> }</div><div><br></div><div>It doesn't look like this is a good place to start a long-running process?</div>
<div><br></div><div>Thanks!</div><div>Josh</div><font color="#888888"><div><br></div></font></div></div><div><div></div><div><div><div class="gmail_quote">On Mon, Sep 7, 2009 at 11:05 PM, Raffaele P. Guidi <span dir="ltr"><<a href="mailto:raffaele.p.guidi@gmail.com" target="_blank">raffaele.p.guidi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">Yes!<div><br></div><div><div><font face="'courier new', monospace">public class LoadDemo : ILoadNotificationPlugin {</font></div>
<div><font face="'courier new', monospace"> public bool Load() {</font></div>
<div><font face="'courier new', monospace"> Log.WriteLine(LogLevel.Notice, "LoadDemo running.");</font></div><div><font face="'courier new', monospace"> return true;</font></div>
<div><font face="'courier new', monospace"> }</font></div><div><font face="'courier new', monospace">}</font></div><div><br></div><div>this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.</div>
<div><br></div><div>And let me add that works like a charm :)</div><div><br></div><div>Ciao,</div><div> Raffaele</div><br><div class="gmail_quote"><div><div></div><div>On Sun, Sep 6, 2009 at 22:50, Josh Rivers <span dir="ltr"><<a href="mailto:josh@radianttiger.com" target="_blank">josh@radianttiger.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div><div></div><div><div>Is there a way to start this when FreeSWITCH starts? The lua and perl modules have a 'startup-script' configuration preference. Is there something similar in mod_managed? Or is there a way to have an api command executed at a startup?</div>
<div><br></div><div><quote author="Phillip Jones"></div><div><div></div><div><div>Exactly what I was after - thank you!</div><div><br></div><div>On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <<a href="mailto:jlenk@frontiernet.net" target="_blank">jlenk@frontiernet.net</a>> wrote:</div>
<div><br></div><div>></div><div>> try something like this</div><div>></div><div>> EventConsumer con = new EventConsumer("all", "");</div><div>> Event ev = con.pop(0);</div><div>></div>
<div>> see lua sample -</div><div>> <a href="http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer" target="_blank">http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer</a></div><div>></div><div>></div>
<div>> Phillip Jones-2 wrote:</div>
<div>> ></div><div>> > Hi there,</div><div>> ></div><div>> > mod_managed exposes EventReceivedFunction such that:</div><div>> ></div><div>> > Session.EventReceivedFunction = (e) =></div>
<div>> > {</div><div>> > Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());</div><div>> > return "";</div><div>> > };</div><div>> ></div><div>
> > should trap all events to which i subscribe.</div><div>> ></div><div>> ></div><div>> > But how do I subscribe to events? What is the .NET / managed equivalent</div><div>> > of:</div><div>
> ></div><div>> > switch_event_bind(const char *id, switch_event_types_t event, const char</div><div>> > *subclass_name, switch_event_callback_t callback, void *user_data);</div><div>> ></div><div>
> ></div><div>> ></div><div>> > Thank you!</div><div>> ></div><div>> ></div><div>> ></div>
</div></div><br></div></div>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>