VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
pjintheusa at gmail.com Guest
|
Posted: Thu Sep 03, 2009 9:36 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent of:
switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
Phillip Jones |
|
Back to top |
|
|
mgg at giagnocavo.net Guest
|
Posted: Thu Sep 03, 2009 10:13 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
You can call switch_event_bind directly, but I doubt that’ll achieve what you want.
My guess is that it works the same as LUA or any of the other plugins – whatever higher level API is exposed for setting up events should make things just work.
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Phillip Jones
Sent: Thursday, September 03, 2009 8:27 AM
To: freeswitch-users@lists.freeswitch.org
Subject: [Freeswitch-users] Subscribing to events in managed C# / .NET
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent of:
switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
Phillip Jones |
|
Back to top |
|
|
mrene_lists at avgs.ca Guest
|
Posted: Thu Sep 03, 2009 10:21 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Check out EventConsumer
Mathieu Rene
Avant-Garde Solutions Inc
Office: + 1 (514) 664-1044 x100
Cell: +1 (514) 664-1044 x200
mrene@avgs.ca (mrene@avgs.ca)
On 3-Sep-09, at 8:05 AM, Michael Giagnocavo wrote:
Quote: | You can call switch_event_bind directly, but I doubt that’ll achieve what you want.
My guess is that it works the same as LUA or any of the other plugins – whatever higher level API is exposed for setting up events should make things just work.
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org (freeswitch-users-bounces@lists.freeswitch.org) [mailto:freeswitch-users-bounces@lists.freeswitch.org (freeswitch-users-bounces@lists.freeswitch.org)] On Behalf Of Phillip Jones
Sent: Thursday, September 03, 2009 8:27 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: [Freeswitch-users] Subscribing to events in managed C# / .NET
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent of:
switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
Phillip Jones
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
|
|
|
Back to top |
|
|
pjintheusa at gmail.com Guest
|
Posted: Thu Sep 03, 2009 10:41 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Where can I find EventConsumer?? I search the wiki and contrib\
Thanks
On Thu, Sep 3, 2009 at 11:12 AM, Mathieu Rene <mrene_lists@avgs.ca (mrene_lists@avgs.ca)> wrote:
Quote: | Check out EventConsumer
Mathieu Rene
Avant-Garde Solutions Inc
Office: + 1 (514) 664-1044 x100
Cell: +1 (514) 664-1044 x200
mrene@avgs.ca (mrene@avgs.ca)
On 3-Sep-09, at 8:05 AM, Michael Giagnocavo wrote:
Quote: |
You can call switch_event_bind directly, but I doubt that’ll achieve what you want.
My guess is that it works the same as LUA or any of the other plugins – whatever higher level API is exposed for setting up events should make things just work.
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org (freeswitch-users-bounces@lists.freeswitch.org) [mailto:freeswitch-users-bounces@lists.freeswitch.org (freeswitch-users-bounces@lists.freeswitch.org)] On Behalf Of Phillip Jones
Sent: Thursday, September 03, 2009 8:27 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: [Freeswitch-users] Subscribing to events in managed C# / .NET
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent of:
switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
Phillip Jones
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
|
|
|
Back to top |
|
|
jlenk at frontiernet.net Guest
|
|
Back to top |
|
|
pjintheusa at gmail.com Guest
|
Posted: Thu Sep 03, 2009 1:11 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
|
|
Back to top |
|
|
josh at radianttiger.com Guest
|
Posted: Mon Sep 07, 2009 1:39 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: |
try something like this
EventConsumer con = new EventConsumer("all", "");
Event ev = con.pop(0);
see lua sample -
http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer
Phillip Jones-2 wrote:
Quote: |
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent
of:
switch_event_bind(const char *id, switch_event_types_t event, const char
*subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
|
|
|
|
Back to top |
|
|
raffaele.p.guidi at gm... Guest
|
Posted: Tue Sep 08, 2009 1:12 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Yes!
public class LoadDemo : ILoadNotificationPlugin {
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
return true;
}
}
this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.
And let me add that works like a charm
Ciao,
Raffaele
On Sun, Sep 6, 2009 at 22:50, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: | 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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: |
try something like this
EventConsumer con = new EventConsumer("all", "");
Event ev = con.pop(0);
see lua sample -
http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer
Phillip Jones-2 wrote:
Quote: |
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent
of:
switch_event_bind(const char *id, switch_event_types_t event, const char
*subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
|
|
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
|
|
|
Back to top |
|
|
josh at radianttiger.com Guest
|
Posted: Tue Sep 08, 2009 1:29 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Thanks for the response!
I have tried putting a long-running loop here, but then it blocks anything else managed from happening:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
}
However, if I fork off a thread here, freeswitch crashes:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
ThreadPool.QueueUserWorkItem((o) =>
{
Log.WriteLine(LogLevel.Notice, "Thread Starting. ");
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
});
return true;
}
}
It doesn't look like this is a good place to start a long-running process?
Thanks!
Josh
On Mon, Sep 7, 2009 at 11:05 PM, Raffaele P. Guidi <raffaele.p.guidi@gmail.com (raffaele.p.guidi@gmail.com)> wrote:
Quote: | Yes!
public class LoadDemo : ILoadNotificationPlugin {
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
return true;
}
}
this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.
And let me add that works like a charm
Ciao,
Raffaele
On Sun, Sep 6, 2009 at 22:50, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: |
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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: |
try something like this
EventConsumer con = new EventConsumer("all", "");
Event ev = con.pop(0);
see lua sample -
http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer
Phillip Jones-2 wrote:
Quote: |
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent
of:
switch_event_bind(const char *id, switch_event_types_t event, const char
*subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
|
|
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
|
|
|
Back to top |
|
|
mgg at giagnocavo.net Guest
|
Posted: Tue Sep 08, 2009 7:17 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Hi,
Can you please elaborate on the crash you receive when you queue a thread during load?
Thanks,
Michael
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Josh Rivers
Sent: Tuesday, September 08, 2009 12:22 AM
To: freeswitch-users@lists.freeswitch.org
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
Thanks for the response!
I have tried putting a long-running loop here, but then it blocks anything else managed from happening:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
}
However, if I fork off a thread here, freeswitch crashes:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
ThreadPool.QueueUserWorkItem((o) =>
{
Log.WriteLine(LogLevel.Notice, "Thread Starting. ");
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
});
return true;
}
}
It doesn't look like this is a good place to start a long-running process?
Thanks!
Josh
On Mon, Sep 7, 2009 at 11:05 PM, Raffaele P. Guidi <raffaele.p.guidi@gmail.com (raffaele.p.guidi@gmail.com)> wrote:
Yes!
public class LoadDemo : ILoadNotificationPlugin {
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
return true;
}
}
this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.
And let me add that works like a charm
Ciao,
Raffaele
On Sun, Sep 6, 2009 at 22:50, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: |
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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: | try something like this
|
Quote: | EventConsumer con = new EventConsumer("all", "");
|
Quote: | Event ev = con.pop(0);
|
Quote: | Phillip Jones-2 wrote:
|
Quote: | Quote: | mod_managed exposes EventReceivedFunction such that:
|
|
Quote: | Quote: | Session.EventReceivedFunction = (e) =>
|
|
Quote: | Quote: | Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
|
|
Quote: | Quote: | should trap all events to which i subscribe.
|
|
Quote: | Quote: | But how do I subscribe to events? What is the .NET / managed equivalent
|
|
Quote: | Quote: | switch_event_bind(const char *id, switch_event_types_t event, const char
|
|
Quote: | Quote: | *subclass_name, switch_event_callback_t callback, void *user_data);
|
|
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org |
|
Back to top |
|
|
raffaele.p.guidi at gm... Guest
|
Posted: Tue Sep 08, 2009 11:16 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Hi, you just have to use delegates to asynchronously call the function containing the loop and return back the control to the calling thread. Here an example (don't have my code at hand, hope it doesn't contain typos).
Regards,
Raffaele
public class TestLoop : ILoadNotificationPlugin
{
Delegate void DoStuffDelegate();
public void doStuff()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
public bool Load()
{
DoStuffDelegate dsdlg = new DoStuffDelegate(doStuff);
dsdlg.BeginInvoke();
}
}
On Tue, Sep 8, 2009 at 08:21, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: | Thanks for the response!
I have tried putting a long-running loop here, but then it blocks anything else managed from happening:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
}
However, if I fork off a thread here, freeswitch crashes:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
ThreadPool.QueueUserWorkItem((o) =>
{
Log.WriteLine(LogLevel.Notice, "Thread Starting. ");
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
});
return true;
}
}
It doesn't look like this is a good place to start a long-running process?
Thanks!
Josh
On Mon, Sep 7, 2009 at 11:05 PM, Raffaele P. Guidi <raffaele.p.guidi@gmail.com (raffaele.p.guidi@gmail.com)> wrote:
Quote: | Yes!
public class LoadDemo : ILoadNotificationPlugin {
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
return true;
}
}
this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.
And let me add that works like a charm
Ciao,
Raffaele
On Sun, Sep 6, 2009 at 22:50, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: |
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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: |
try something like this
EventConsumer con = new EventConsumer("all", "");
Event ev = con.pop(0);
see lua sample -
http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer
Phillip Jones-2 wrote:
Quote: |
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent
of:
switch_event_bind(const char *id, switch_event_types_t event, const char
*subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
|
|
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
|
|
|
Back to top |
|
|
mgg at giagnocavo.net Guest
|
Posted: Tue Sep 08, 2009 11:56 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
That’s what his sample does, but he says it crashes.
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Raffaele P. Guidi
Sent: Tuesday, September 08, 2009 10:08 AM
To: freeswitch-users@lists.freeswitch.org
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
Hi, you just have to use delegates to asynchronously call the function containing the loop and return back the control to the calling thread. Here an example (don't have my code at hand, hope it doesn't contain typos).
Regards,
Raffaele
public class TestLoop : ILoadNotificationPlugin
{
Delegate void DoStuffDelegate();
public void doStuff()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
public bool Load()
{
DoStuffDelegate dsdlg = new DoStuffDelegate(doStuff);
dsdlg.BeginInvoke();
}
}
On Tue, Sep 8, 2009 at 08:21, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Thanks for the response!
I have tried putting a long-running loop here, but then it blocks anything else managed from happening:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
}
However, if I fork off a thread here, freeswitch crashes:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
ThreadPool.QueueUserWorkItem((o) =>
{
Log.WriteLine(LogLevel.Notice, "Thread Starting. ");
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
});
return true;
}
}
It doesn't look like this is a good place to start a long-running process?
Thanks!
Josh
On Mon, Sep 7, 2009 at 11:05 PM, Raffaele P. Guidi <raffaele.p.guidi@gmail.com (raffaele.p.guidi@gmail.com)> wrote:
Yes!
public class LoadDemo : ILoadNotificationPlugin {
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
return true;
}
}
this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.
And let me add that works like a charm
Ciao,
Raffaele
On Sun, Sep 6, 2009 at 22:50, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: |
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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: | try something like this
|
Quote: | EventConsumer con = new EventConsumer("all", "");
|
Quote: | Event ev = con.pop(0);
|
Quote: | Phillip Jones-2 wrote:
|
Quote: | Quote: | mod_managed exposes EventReceivedFunction such that:
|
|
Quote: | Quote: | Session.EventReceivedFunction = (e) =>
|
|
Quote: | Quote: | Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
|
|
Quote: | Quote: | should trap all events to which i subscribe.
|
|
Quote: | Quote: | But how do I subscribe to events? What is the .NET / managed equivalent
|
|
Quote: | Quote: | switch_event_bind(const char *id, switch_event_types_t event, const char
|
|
Quote: | Quote: | *subclass_name, switch_event_callback_t callback, void *user_data);
|
|
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org |
|
Back to top |
|
|
pjintheusa at gmail.com Guest
|
Posted: Tue Sep 08, 2009 1:19 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
What is:
freeswitch.msleep(100);
Why aren't you using Thread.Sleep?
On Tue, Sep 8, 2009 at 2:21 AM, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: | Thanks for the response!
I have tried putting a long-running loop here, but then it blocks anything else managed from happening:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
}
However, if I fork off a thread here, freeswitch crashes:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
ThreadPool.QueueUserWorkItem((o) =>
{
Log.WriteLine(LogLevel.Notice, "Thread Starting. ");
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
});
return true;
}
}
It doesn't look like this is a good place to start a long-running process?
Thanks!
Josh
On Mon, Sep 7, 2009 at 11:05 PM, Raffaele P. Guidi <raffaele.p.guidi@gmail.com (raffaele.p.guidi@gmail.com)> wrote:
Quote: | Yes!
public class LoadDemo : ILoadNotificationPlugin {
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
return true;
}
}
this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.
And let me add that works like a charm
Ciao,
Raffaele
On Sun, Sep 6, 2009 at 22:50, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: |
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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: |
try something like this
EventConsumer con = new EventConsumer("all", "");
Event ev = con.pop(0);
see lua sample -
http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer
Phillip Jones-2 wrote:
Quote: |
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent
of:
switch_event_bind(const char *id, switch_event_types_t event, const char
*subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
|
|
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
|
|
|
Back to top |
|
|
raffaele.p.guidi at gm... Guest
|
Posted: Tue Sep 08, 2009 1:32 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Well, I can't see any delegate in josh sample, just a ThreadPool.QueueUserWorkItem. Here is an example that, at least on my system (I reached my home pc in the meanwhile), works fine.
public class LoadPluginDemo : ILoadNotificationPlugin {
delegate void Listener();
private void EventListener() {
EventConsumer con = new EventConsumer("all", null);
while (true){
Event ev = con.pop(1);
Log.WriteLine(LogLevel.Notice, "Got event " + ev.GetHeader("Event-Name"));
}
}
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
new Listener(EventListener).BeginInvoke(null,null);
return true;
}
}
On Tue, Sep 8, 2009 at 18:43, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Quote: |
That’s what his sample does, but he says it crashes.
From: freeswitch-users-bounces@lists.freeswitch.org (freeswitch-users-bounces@lists.freeswitch.org) [mailto:freeswitch-users-bounces@lists.freeswitch.org (freeswitch-users-bounces@lists.freeswitch.org)] On Behalf Of Raffaele P. Guidi
Sent: Tuesday, September 08, 2009 10:08 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
Hi, you just have to use delegates to asynchronously call the function containing the loop and return back the control to the calling thread. Here an example (don't have my code at hand, hope it doesn't contain typos).
Regards,
Raffaele
public class TestLoop : ILoadNotificationPlugin
{
Delegate void DoStuffDelegate();
public void doStuff()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
public bool Load()
{
DoStuffDelegate dsdlg = new DoStuffDelegate(doStuff);
dsdlg.BeginInvoke();
}
}
On Tue, Sep 8, 2009 at 08:21, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Thanks for the response!
I have tried putting a long-running loop here, but then it blocks anything else managed from happening:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
}
However, if I fork off a thread here, freeswitch crashes:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
ThreadPool.QueueUserWorkItem((o) =>
{
Log.WriteLine(LogLevel.Notice, "Thread Starting. ");
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
});
return true;
}
}
It doesn't look like this is a good place to start a long-running process?
Thanks!
Josh
On Mon, Sep 7, 2009 at 11:05 PM, Raffaele P. Guidi <raffaele.p.guidi@gmail.com (raffaele.p.guidi@gmail.com)> wrote:
Yes!
public class LoadDemo : ILoadNotificationPlugin {
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
return true;
}
}
this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.
And let me add that works like a charm
Ciao,
Raffaele
On Sun, Sep 6, 2009 at 22:50, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: |
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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: | try something like this
|
Quote: | EventConsumer con = new EventConsumer("all", "");
|
Quote: | Event ev = con.pop(0);
|
Quote: | Phillip Jones-2 wrote:
|
Quote: | Quote: | mod_managed exposes EventReceivedFunction such that:
|
|
Quote: | Quote: | Session.EventReceivedFunction = (e) =>
|
|
Quote: | Quote: | Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
|
|
Quote: | Quote: | should trap all events to which i subscribe.
|
|
Quote: | Quote: | But how do I subscribe to events? What is the .NET / managed equivalent
|
|
Quote: | Quote: | switch_event_bind(const char *id, switch_event_types_t event, const char
|
|
Quote: | Quote: | *subclass_name, switch_event_callback_t callback, void *user_data);
|
|
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
|
|
|
Back to top |
|
|
raffaele.p.guidi at gm... Guest
|
Posted: Tue Sep 08, 2009 2:07 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
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
On Tue, Sep 8, 2009 at 20:12, Phillip Jones <pjintheusa@gmail.com (pjintheusa@gmail.com)> wrote:
Quote: | What is:
freeswitch.msleep(100);
Why aren't you using Thread.Sleep?
On Tue, Sep 8, 2009 at 2:21 AM, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: | Thanks for the response!
I have tried putting a long-running loop here, but then it blocks anything else managed from happening:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
}
}
However, if I fork off a thread here, freeswitch crashes:
public class TestLoop : ILoadNotificationPlugin
{
public bool Load()
{
ThreadPool.QueueUserWorkItem((o) =>
{
Log.WriteLine(LogLevel.Notice, "Thread Starting. ");
EventConsumer con = new EventConsumer("all", "");
while (true)
{
Event ev = con.pop(0);
Log.WriteLine(LogLevel.Notice, "Event: " + ev.serialized_string);
freeswitch.msleep(100);
}
});
return true;
}
}
It doesn't look like this is a good place to start a long-running process?
Thanks!
Josh
On Mon, Sep 7, 2009 at 11:05 PM, Raffaele P. Guidi <raffaele.p.guidi@gmail.com (raffaele.p.guidi@gmail.com)> wrote:
Quote: | Yes!
public class LoadDemo : ILoadNotificationPlugin {
public bool Load() {
Log.WriteLine(LogLevel.Notice, "LoadDemo running.");
return true;
}
}
this example is from Michael Giagnocavo's Demo.csx which you can find into the mod_managed svn.
And let me add that works like a charm
Ciao,
Raffaele
On Sun, Sep 6, 2009 at 22:50, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: |
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?
<quote author="Phillip Jones">
Exactly what I was after - thank you!
On Thu, Sep 3, 2009 at 1:54 PM, Jeff Lenk <jlenk@frontiernet.net (jlenk@frontiernet.net)> wrote:
Quote: |
try something like this
EventConsumer con = new EventConsumer("all", "");
Event ev = con.pop(0);
see lua sample -
http://wiki.freeswitch.org/wiki/Lua#freeswitch.EventConsumer
Phillip Jones-2 wrote:
Quote: |
Hi there,
mod_managed exposes EventReceivedFunction such that:
Session.EventReceivedFunction = (e) =>
{
Log.WriteLine(LogLevel.Alert, "Received Event {0}", e.ToString());
return "";
};
should trap all events to which i subscribe.
But how do I subscribe to events? What is the .NET / managed equivalent
of:
switch_event_bind(const char *id, switch_event_types_t event, const char
*subclass_name, switch_event_callback_t callback, void *user_data);
Thank you!
|
|
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@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@lists.freeswitch.org (FreeSWITCH-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
|
|
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|