Yeah, probably just using con.pop(1) - that waits for an event to be caught, instead than con.pop(0), thus avoiding &quot;sleeps&quot; would do the trick<br><br><div class="gmail_quote">On Tue, Sep 8, 2009 at 20:12, Phillip Jones <span dir="ltr">&lt;<a href="mailto:pjintheusa@gmail.com">pjintheusa@gmail.com</a>&gt;</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&#39;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">&lt;<a href="mailto:josh@radianttiger.com" target="_blank">josh@radianttiger.com</a>&gt;</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(&quot;all&quot;, &quot;&quot;);</div></div><div>            while (true)</div>
<div><div>            {</div>
<div>                Event ev = con.pop(0);</div></div><div>                Log.WriteLine(LogLevel.Notice, &quot;Event: &quot; + 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) =&gt;</div><div>            {</div><div>                Log.WriteLine(LogLevel.Notice, &quot;Thread Starting. &quot;);</div><div><div>                EventConsumer con = new EventConsumer(&quot;all&quot;, &quot;&quot;);</div>


</div><div>                while (true)</div><div><div>                {</div><div>                    Event ev = con.pop(0);</div></div><div>                    Log.WriteLine(LogLevel.Notice, &quot;Event: &quot; + 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&#39;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">&lt;<a href="mailto:raffaele.p.guidi@gmail.com" target="_blank">raffaele.p.guidi@gmail.com</a>&gt;</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="&#39;courier new&#39;, monospace">public class LoadDemo : ILoadNotificationPlugin {</font></div>


<div><font face="&#39;courier new&#39;, monospace">    public bool Load() {</font></div>
<div><font face="&#39;courier new&#39;, monospace">        Log.WriteLine(LogLevel.Notice, &quot;LoadDemo running.&quot;);</font></div><div><font face="&#39;courier new&#39;, monospace">        return true;</font></div>
<div><font face="&#39;courier new&#39;, monospace">    }</font></div><div><font face="&#39;courier new&#39;, monospace">}</font></div><div><br></div><div>this example is from Michael Giagnocavo&#39;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">&lt;<a href="mailto:josh@radianttiger.com" target="_blank">josh@radianttiger.com</a>&gt;</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 &#39;startup-script&#39; 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>&lt;quote author=&quot;Phillip Jones&quot;&gt;</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 &lt;<a href="mailto:jlenk@frontiernet.net" target="_blank">jlenk@frontiernet.net</a>&gt; wrote:</div>




<div><br></div><div>&gt;</div><div>&gt; try something like this</div><div>&gt;</div><div>&gt; EventConsumer con = new EventConsumer(&quot;all&quot;, &quot;&quot;);</div><div>&gt; Event ev = con.pop(0);</div><div>&gt;</div>




<div>&gt; see lua sample -</div><div>&gt; <a href="http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer" target="_blank">http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer</a></div><div>&gt;</div><div>&gt;</div>



<div>&gt; Phillip Jones-2 wrote:</div>
<div>&gt; &gt;</div><div>&gt; &gt; Hi there,</div><div>&gt; &gt;</div><div>&gt; &gt; mod_managed exposes EventReceivedFunction such that:</div><div>&gt; &gt;</div><div>&gt; &gt;  Session.EventReceivedFunction = (e) =&gt;</div>




<div>&gt; &gt;  {</div><div>&gt; &gt;        Log.WriteLine(LogLevel.Alert, &quot;Received Event {0}&quot;, e.ToString());</div><div>&gt; &gt;        return &quot;&quot;;</div><div>&gt; &gt;  };</div><div>&gt; &gt;</div><div>




&gt; &gt; should trap all events to which i subscribe.</div><div>&gt; &gt;</div><div>&gt; &gt;</div><div>&gt; &gt; But how do I subscribe to events? What is the .NET / managed equivalent</div><div>&gt; &gt; of:</div><div>




&gt; &gt;</div><div>&gt; &gt; switch_event_bind(const char *id, switch_event_types_t event, const char</div><div>&gt; &gt; *subclass_name, switch_event_callback_t callback, void *user_data);</div><div>&gt; &gt;</div><div>




&gt; &gt;</div><div>&gt; &gt;</div><div>&gt; &gt; Thank you!</div><div>&gt; &gt;</div><div>&gt; &gt;</div><div>&gt; &gt;</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>