[Freeswitch-users] Subscribing to events in managed C# / .NET

Josh Rivers josh at radianttiger.com
Wed Sep 9 13:40:56 PDT 2009


  kernel32.dll!77e4bef7()
Here's that call stack.

  [Frames below may be incorrect and/or missing, no symbols loaded for
kernel32.dll]
  kernel32.dll!77e4bef7()
  msvcr80.dll!78158e89()
  mscorwks.dll!79e7a17a()
  mscorwks.dll!79ea0fa8()
  mscorwks.dll!79ea0eff()
  mscorwks.dll!79e976cc()
  mscorwks.dll!79e976b3()
  mscorwks.dll!79e9e3bd()
  mscorwks.dll!79e970c8()
  mscorwks.dll!79f782f1()
  mscorwks.dll!79eaa5c5()
  mscorwks.dll!79eaad29()
  mscorwks.dll!79e9a15d()
  mscorwks.dll!79e9a15d()
  mscorwks.dll!79e7a1f1()
  mscorwks.dll!79e7a1f1()
  mscorwks.dll!79e7a17a()
  mscorwks.dll!79e88cca()
  mscorwks.dll!79e96571()
  mscorwks.dll!79e965a4()
  mscorwks.dll!79e965c2()
  mscorwks.dll!79f59330()
  mscorwks.dll!79f59492()
  mscorlib.ni.dll!792d5348()
  mscorlib.ni.dll!792d514f()
  mscorlib.ni.dll!792d4fde()
  mscorlib.ni.dll!79799714()
  mscorwks.dll!79e813e4()
  mscorwks.dll!79e813ec()
> FreeSwitch.dll!switch_loadable_module_load_file(char * path=0x01181250,
char * filename=0x01181240, switch_bool_t global=SWITCH_FALSE,
switch_loadable_module * * new_module=0x0012d9e0)  Line 846 + 0xd bytes C
  FreeSwitch.dll!switch_loadable_module_load_module_ex(char *
dir=0x003994a8, char * fname=0x01081d59, switch_bool_t runtime=SWITCH_FALSE,
switch_bool_t global=SWITCH_FALSE, const char * * err=0x0012da5c)  Line 942
+ 0x15 bytes C
  FreeSwitch.dll!switch_loadable_module_init()  Line 1174 + 0x23 bytes C
  FreeSwitch.dll!switch_core_init_and_modload(unsigned int flags=129,
switch_bool_t console=SWITCH_TRUE, const char * * err=0x0012fdec)  Line 1469
+ 0x5 bytes C
  FreeSwitch.exe!main(int argc=1, char * * argv=0x00394f80)  Line 748 + 0x23
bytes C
  FreeSwitch.exe!__tmainCRTStartup()  Line 586 + 0x19 bytes C
  FreeSwitch.exe!mainCRTStartup()  Line 403 C
  kernel32.dll!77e6f23b()

The breakpoint is: status = load_func_ptr(&module_interface, pool);
Line 846 in switch_loadable_module.c

--Josh

On Tue, Sep 8, 2009 at 10:50 PM, Josh Rivers <josh at radianttiger.com> wrote:

> I'm running of the binary release, so I don't have debug symbols for the
> freeswitch core. I can do a build...but does somebody else already have one
> handy? -Josh
>
>
> On Tue, Sep 8, 2009 at 10:33 PM, Mathieu Rene <mrene_lists at avgs.ca> wrote:
>
>> Click Break, then go in Window, Debug, Stack Trace (or something similar,
>> I don't have any VS nearby), then copy paste that.
>>  Mathieu Rene
>> Avant-Garde Solutions Inc
>> Office: + 1 (514) 664-1044 x100
>> Cell: +1 (514) 664-1044 x200
>> mrene at avgs.ca
>>
>>
>>
>>
>> On 8-Sep-09, at 10:30 PM, Josh Rivers wrote:
>>
>> Here is the error I get with the loop I mentioned. -Josh
>> <Capture.PNG>
>>
>> On Tue, Sep 8, 2009 at 5:05 AM, Michael Giagnocavo <mgg at giagnocavo.net>wrote:
>>
>>>  Hi,
>>>
>>>
>>>                 Can you please elaborate on the crash you receive when
>>> you queue a thread during load?
>>>
>>>
>>> Thanks,
>>>
>>> Michael
>>>
>>>
>>> *From:* freeswitch-users-bounces at lists.freeswitch.org [mailto:
>>> freeswitch-users-bounces at lists.freeswitch.org] *On Behalf Of *Josh
>>> Rivers
>>> *Sent:* Tuesday, September 08, 2009 12:22 AM
>>> *To:* freeswitch-users at 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 at 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 at radianttiger.com> wrote:
>>>
>>>  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 at frontiernet.net> wrote:
>>>
>>>
>>> >
>>>
>>> > 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:
>>>
>>> > >
>>>
>>> > > 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 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
>>>
>>>
>>> _______________________________________________
>>> 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
>>
>>
>>
>> _______________________________________________
>> 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/20090909/f4aeee18/attachment-0002.html 


More information about the FreeSWITCH-users mailing list