VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
mgg at giagnocavo.net Guest
|
Posted: Thu Sep 24, 2009 3:12 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
|
I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
|
No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
|
This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
|
I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh |
|
Back to top |
|
|
mike at jerris.com Guest
|
Posted: Thu Sep 24, 2009 11:39 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
There are a few other things I can think would be nice additions to mod_managed. Maybe an event handler that does not require a thread to be sitting and waiting for events trying in a loop would be nice, instead something that is triggered each time there is a certain event class triggered. Also, there has been some interest in doing full endpoint modules in mod_managed. exposing all the state handlers in .net like ways and having that all work would be quite interesting, but probably requires someone specific actually ready to write a module like that to be worthwhile.
Mike
On Sep 24, 2009, at 4:01 AM, Michael Giagnocavo wrote:
Quote: | Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org (freeswitch-users-bounces@lists.freeswitch.org) [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
| I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
| No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
| This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
| I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh
_______________________________________________
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: Fri Sep 25, 2009 3:23 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
There is a new function I checked in a little bit ago that lets you create any of the SWIGTYPE_p_xxx types – all you need is a pointer to the memory to represent whatever it is in native land. So with that, it’s actually possible to call most or all of the functions. (Yes DRK, you can now go do XML binding.) But sure, it’d be nice to make a real .NET-ish layer.
Async events seems like it wouldn’t be hard, assuming FreeSWITCH delivers them that way?
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Jerris
Sent: Thursday, September 24, 2009 10:26 PM
To: freeswitch-users@lists.freeswitch.org
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
There are a few other things I can think would be nice additions to mod_managed. Maybe an event handler that does not require a thread to be sitting and waiting for events trying in a loop would be nice, instead something that is triggered each time there is a certain event class triggered. Also, there has been some interest in doing full endpoint modules in mod_managed. exposing all the state handlers in .net like ways and having that all work would be quite interesting, but probably requires someone specific actually ready to write a module like that to be worthwhile.
Mike
On Sep 24, 2009, at 4:01 AM, Michael Giagnocavo wrote:
Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org (freeswitch-users-bounces@lists.freeswitch.org) [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
|
I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
|
No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
|
This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
|
I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh
_______________________________________________
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: Sat Sep 26, 2009 7:27 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Sorry for fading off for a few days. Having too much fun doing stuff!
A few responses:
On Thu, Sep 24, 2009 at 1:01 AM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Quote: |
A few questions I have:
Testability – is this even remotely practical?
| I've seen three areas of testability:
1) Interop
2) Module Extensibility Framework
3) Modules and Plugins
The interop testability picture is not an area I'm very familiar. I imagine you could write a native mod_managed.dll testing shim and test against that. I think this would have some limited value. It would confirm that interop layers behaved as expected, but not much more. The biggest values would be a) verifying that the api doesn't change accidentally, and b) providing a good way of adding bug-solution cases when the behavior of the core is causing a failure that we need to provide some padding around.
The extensibility portion is very easy to write tests for. The module loader framework that I've refactored out of your code is completely stupid about the unmanaged code. It blindly passes the pointers through to the consumers that want them, and all of the module loader responsibilities are in managed code and mostly coded to interface. Very easy to mock and test.
Finally the plugin testability story. Currently this is harder, since the plugins are written to talk to a lot of static methods and direct unmanaged types. As things evolve, I'd want to create a updated plugin interface that passes all the interop points by interface. The unit testing responsibility for an app or api plugin should primarily be that for a given set of inputs or responses, it makes a specified set of calls. That should be possible to mock and test in managed code if we provide a thin managed interface layer over the P/Invoke|SWIG layer. I'm currently writing a plugin that does just this, but I have the interface layer inside my code. Not everyone should have to write their own though?
Quote: |
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.?
| I'm going to be a bit long-winded here. I hope I can clarify my intent, because I think I've been unclear on it so far.
A) Philosophy: I have two principal concepts that are guiding me in my push towards modularity.
1) Single Responsibility Principal: "Each class or code file should only have one reason to change." I don't think I'm quite here in the code I've shown you, but it's getting closer. (I could definitely use help.) The idea here is that the class that monitors the plugin directory shouldn't also load the files. The class that loads the files shouldn't be responsible for configuring and creating app domains. Neither of those classes should have concrete logging code in them. The good thing about this is that you don't have to worry about breaking the loader when you change the watcher, and vice-versa. If we later decide to change the watcher so that it only checks for updates manually, we don't need to even let the loader know.
2) Open-Closed Principal: "Classes should be open for extension and closed for modification." The idea here is that once we've written a working class that has it's bugs ironed out and it's unit tests written, we shouldn't (ideally) ever need to change it. If we need a new behavior, we can just subclass the original, or implement the same interface, or whatever, and use the new class instead of the old one. If everything is nice an loosely coupled, we can just slide the new implementation in for improved behavior without changing the old one. What this means for the module system is that we can create new functionality without breaking old functionality.
B) Actual uses: (Please note, that in most cases, I don't think that mod_managed needs to build out these functions, rather, I think mod_managed should "get out of the way" and let developers plug in what they want)
1) Commercial PBX Developer/Distributor:
Case: Say I want to write my own FreeSWITCH distro/UI/packaged software on Windows, and I want to do all of my development in managed code and I don't care about plugins or anything.
Answer: recompile my managed.dll with just a few changed lines in Loader.cs and your code controls everything coming into mod_managed. Ultimate power. Roll your own. Use it to launch a UI. Go nutz.
2) Complicated interwoven plugins:
Case: I want to write a bunch of plugin dlls and have them all cross-communicate and share caches and statics.
Answer: provide your own implementation of IModuleLoader and plug it into the registry. Now you can eliminate all of those pesky appdomains that prevent your cross-plugin communication. Sure, you'll have to reload the switch when you want to reload a plugin, but that's not such a big deal. (Or if it is, you can try loading all your plugins into the same appdomain and reload that every time. It's up to you.)
3) New and Improved(TM) Plugin Model
Case: You and I decide that the way we're calling the current plugins, passing them contexts and sessions, is completely dated and we want to change it to something new.
Answer: instead of changing the current plugin api, we just add a set of loaders and handlers for the New and Improved(TM) plugin interfaces. We roll that into the managed.dll. Now folk can write old plugins and new plugins, don't need to recompile, and everybody's happy. In a year or two we can start deprecating the old interfaces and get people moving to the modern ones, if we feel strongly about it.
4) Aspect oriented plugins
Case: I want to report every time a managed api call is made to a web service, and I don't want to change the existing plugin code.
Answer: write a new Execute and ExecuteBackground handler, and register it. Have your handler fire for _all_ arguments, rather than filtering on the first argument. Send your logging info off with a web service call.
These are all things that can be done with the structure I've outlined.
What may be more intersting than all of these, later, is plugins that interact with the event model to provide in-process ESL-type control of the FS.
Quote: |
Thanks for putting up with me!
|
Thank _you_ for helping me get my thoughts out more clearly.
Josh |
|
Back to top |
|
|
josh at radianttiger.com Guest
|
Posted: Sat Sep 26, 2009 7:28 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
I don't know what we'd want to write endpoints for, so I'll leave that one alone...
I do, however, agree with you on the event handler idea. My work on the module system is largely a precursor to putting in some work on a pub/sub event bus in managed code. I wanted some lifecycle and exception handling control that wasn't easy in the existing dll and I wanted to be able to create it without breaking stuff for other people.
My question is this: is an event bus a good thing to put in mod_managed, or should it be an optional plugin that you load in?
Josh
On Thu, Sep 24, 2009 at 9:26 PM, Michael Jerris <mike@jerris.com (mike@jerris.com)> wrote:
Quote: | There are a few other things I can think would be nice additions to mod_managed. Maybe an event handler that does not require a thread to be sitting and waiting for events trying in a loop would be nice, instead something that is triggered each time there is a certain event class triggered. Also, there has been some interest in doing full endpoint modules in mod_managed. exposing all the state handlers in .net like ways and having that all work would be quite interesting, but probably requires someone specific actually ready to write a module like that to be worthwhile.
Mike
On Sep 24, 2009, at 4:01 AM, Michael Giagnocavo wrote:
Quote: |
Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-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 Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
| I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
| No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
| This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
| I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh
_______________________________________________
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 |
|
|
josh at radianttiger.com Guest
|
Posted: Sun Sep 27, 2009 12:39 am Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
The ability to directly create swigtypes...that's huge! I'd love to see some examples of how to use that.
I've update my refactoring to include the changes to the trunk up through r14981. I've also checked in updated binaries that should work with the latest trunk builds(I hope?)
A question occurred to me: would it make any sense to push the plugin loader into a separate DLL? That way we could keep the P/Invoke layer very cleanly separated from the loader/process host/abstraction layer structures.
Josh
On Fri, Sep 25, 2009 at 1:13 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Quote: |
There is a new function I checked in a little bit ago that lets you create any of the SWIGTYPE_p_xxx types – all you need is a pointer to the memory to represent whatever it is in native land. So with that, it’s actually possible to call most or all of the functions. (Yes DRK, you can now go do XML binding.) But sure, it’d be nice to make a real .NET-ish layer.
Async events seems like it wouldn’t be hard, assuming FreeSWITCH delivers them that way?
-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 Michael Jerris
Sent: Thursday, September 24, 2009 10:26 PM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
There are a few other things I can think would be nice additions to mod_managed. Maybe an event handler that does not require a thread to be sitting and waiting for events trying in a loop would be nice, instead something that is triggered each time there is a certain event class triggered. Also, there has been some interest in doing full endpoint modules in mod_managed. exposing all the state handlers in .net like ways and having that all work would be quite interesting, but probably requires someone specific actually ready to write a module like that to be worthwhile.
Mike
On Sep 24, 2009, at 4:01 AM, Michael Giagnocavo wrote:
Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-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 Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
|
I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
|
No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
|
This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
|
I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh
_______________________________________________
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 |
|
|
josh at radianttiger.com Guest
|
Posted: Sun Sep 27, 2009 3:58 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
One more addition added. The loader process now looks for the string ".primary" in the filename. If it exists, it loads the dll into the primary appdomain and executes to Load() routine on implementors of IPrimaryAppdomainExtension. I also added an example showing the use of this to display a WinForm logger.
http://github.com/joshrivers/FreeSWITCH.Managed
On Sat, Sep 26, 2009 at 10:28 PM, Josh Rivers <josh@radianttiger.com (josh@radianttiger.com)> wrote:
Quote: | The ability to directly create swigtypes...that's huge! I'd love to see some examples of how to use that.
I've update my refactoring to include the changes to the trunk up through r14981. I've also checked in updated binaries that should work with the latest trunk builds(I hope?)
A question occurred to me: would it make any sense to push the plugin loader into a separate DLL? That way we could keep the P/Invoke layer very cleanly separated from the loader/process host/abstraction layer structures.
Josh
On Fri, Sep 25, 2009 at 1:13 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Quote: |
There is a new function I checked in a little bit ago that lets you create any of the SWIGTYPE_p_xxx types – all you need is a pointer to the memory to represent whatever it is in native land. So with that, it’s actually possible to call most or all of the functions. (Yes DRK, you can now go do XML binding.) But sure, it’d be nice to make a real .NET-ish layer.
Async events seems like it wouldn’t be hard, assuming FreeSWITCH delivers them that way?
-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 Michael Jerris
Sent: Thursday, September 24, 2009 10:26 PM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
There are a few other things I can think would be nice additions to mod_managed. Maybe an event handler that does not require a thread to be sitting and waiting for events trying in a loop would be nice, instead something that is triggered each time there is a certain event class triggered. Also, there has been some interest in doing full endpoint modules in mod_managed. exposing all the state handlers in .net like ways and having that all work would be quite interesting, but probably requires someone specific actually ready to write a module like that to be worthwhile.
Mike
On Sep 24, 2009, at 4:01 AM, Michael Giagnocavo wrote:
Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-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 Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
|
I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
|
No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
|
This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
|
I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh
_______________________________________________
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: Sun Sep 27, 2009 6:19 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
It’s in the “FSUtil” class (no I’m not happy with the name). I also made it an extension method on IntPtr (I’m not a big fan of extension methods, but the code is sorta messy anyways, so it’s not relatively bad.)
var x = CreateSwigTypePointer<SWIGTYPE_p_int>(somePtr);
Moving stuff out of the SWIG DLL removes the ability to use partial classes to extend the generated swigtypes. This is used a bit, and will be used a lot more as the managed plugin is cleaned up. For example, most of the FS APIs return string, when they should return a better representation. Also, the constructors for some of the types are internal only, and I don’t really enjoy using reflection to create them.
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Josh Rivers
Sent: Saturday, September 26, 2009 11:29 PM
To: freeswitch-users@lists.freeswitch.org
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
The ability to directly create swigtypes...that's huge! I'd love to see some examples of how to use that.
I've update my refactoring to include the changes to the trunk up through r14981. I've also checked in updated binaries that should work with the latest trunk builds(I hope?)
A question occurred to me: would it make any sense to push the plugin loader into a separate DLL? That way we could keep the P/Invoke layer very cleanly separated from the loader/process host/abstraction layer structures.
Josh
On Fri, Sep 25, 2009 at 1:13 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
There is a new function I checked in a little bit ago that lets you create any of the SWIGTYPE_p_xxx types – all you need is a pointer to the memory to represent whatever it is in native land. So with that, it’s actually possible to call most or all of the functions. (Yes DRK, you can now go do XML binding.) But sure, it’d be nice to make a real .NET-ish layer.
Async events seems like it wouldn’t be hard, assuming FreeSWITCH delivers them that way?
-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 Michael Jerris
Sent: Thursday, September 24, 2009 10:26 PM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
There are a few other things I can think would be nice additions to mod_managed. Maybe an event handler that does not require a thread to be sitting and waiting for events trying in a loop would be nice, instead something that is triggered each time there is a certain event class triggered. Also, there has been some interest in doing full endpoint modules in mod_managed. exposing all the state handlers in .net like ways and having that all work would be quite interesting, but probably requires someone specific actually ready to write a module like that to be worthwhile.
Mike
On Sep 24, 2009, at 4:01 AM, Michael Giagnocavo wrote:
Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-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 Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
|
I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
|
No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
|
This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
|
I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh
_______________________________________________
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 |
|
|
josh at radianttiger.com Guest
|
Posted: Sun Sep 27, 2009 10:48 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
Where does 'somePtr' come from?
On Sun, Sep 27, 2009 at 4:06 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Quote: |
It’s in the “FSUtil” class (no I’m not happy with the name). I also made it an extension method on IntPtr (I’m not a big fan of extension methods, but the code is sorta messy anyways, so it’s not relatively bad.)
var x = CreateSwigTypePointer<SWIGTYPE_p_int>(somePtr);
Moving stuff out of the SWIG DLL removes the ability to use partial classes to extend the generated swigtypes. This is used a bit, and will be used a lot more as the managed plugin is cleaned up. For example, most of the FS APIs return string, when they should return a better representation. Also, the constructors for some of the types are internal only, and I don’t really enjoy using reflection to create them.
-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 Josh Rivers
Sent: Saturday, September 26, 2009 11:29 PM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
The ability to directly create swigtypes...that's huge! I'd love to see some examples of how to use that.
I've update my refactoring to include the changes to the trunk up through r14981. I've also checked in updated binaries that should work with the latest trunk builds(I hope?)
A question occurred to me: would it make any sense to push the plugin loader into a separate DLL? That way we could keep the P/Invoke layer very cleanly separated from the loader/process host/abstraction layer structures.
Josh
On Fri, Sep 25, 2009 at 1:13 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
There is a new function I checked in a little bit ago that lets you create any of the SWIGTYPE_p_xxx types – all you need is a pointer to the memory to represent whatever it is in native land. So with that, it’s actually possible to call most or all of the functions. (Yes DRK, you can now go do XML binding.) But sure, it’d be nice to make a real .NET-ish layer.
Async events seems like it wouldn’t be hard, assuming FreeSWITCH delivers them that way?
-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 Michael Jerris
Sent: Thursday, September 24, 2009 10:26 PM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
There are a few other things I can think would be nice additions to mod_managed. Maybe an event handler that does not require a thread to be sitting and waiting for events trying in a loop would be nice, instead something that is triggered each time there is a certain event class triggered. Also, there has been some interest in doing full endpoint modules in mod_managed. exposing all the state handlers in .net like ways and having that all work would be quite interesting, but probably requires someone specific actually ready to write a module like that to be worthwhile.
Mike
On Sep 24, 2009, at 4:01 AM, Michael Giagnocavo wrote:
Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-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 Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
|
I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
|
No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
|
This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
|
I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh
_______________________________________________
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: Sun Sep 27, 2009 11:11 pm Post subject: [Freeswitch-users] Subscribing to events in managed C# / .NE |
|
|
You make it however you want. Marshal.StructureToPtr, AllocCoTaskMem; GCHandle.Alloc/GetAddrOfPinnedObject; stackalloc (C#); Ref.pin (F#). You can get it from unmanaged code (you could just P/Invoke malloc if you want). And I think the SWIGTYPEs expose a GCHandle so you can get their pointer if you need to convert their type.
If it’s a complex structure that swig hasn’t created, and you really want nice typed access to it, you may want to create a nice struct in C# for marshalling.
-Michael
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Josh Rivers
Sent: Sunday, September 27, 2009 9:36 PM
To: freeswitch-users@lists.freeswitch.org
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
Where does 'somePtr' come from?
On Sun, Sep 27, 2009 at 4:06 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
It’s in the “FSUtil” class (no I’m not happy with the name). I also made it an extension method on IntPtr (I’m not a big fan of extension methods, but the code is sorta messy anyways, so it’s not relatively bad.)
var x = CreateSwigTypePointer<SWIGTYPE_p_int>(somePtr);
Moving stuff out of the SWIG DLL removes the ability to use partial classes to extend the generated swigtypes. This is used a bit, and will be used a lot more as the managed plugin is cleaned up. For example, most of the FS APIs return string, when they should return a better representation. Also, the constructors for some of the types are internal only, and I don’t really enjoy using reflection to create them.
-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 Josh Rivers
Sent: Saturday, September 26, 2009 11:29 PM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
The ability to directly create swigtypes...that's huge! I'd love to see some examples of how to use that.
I've update my refactoring to include the changes to the trunk up through r14981. I've also checked in updated binaries that should work with the latest trunk builds(I hope?)
A question occurred to me: would it make any sense to push the plugin loader into a separate DLL? That way we could keep the P/Invoke layer very cleanly separated from the loader/process host/abstraction layer structures.
Josh
On Fri, Sep 25, 2009 at 1:13 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
There is a new function I checked in a little bit ago that lets you create any of the SWIGTYPE_p_xxx types – all you need is a pointer to the memory to represent whatever it is in native land. So with that, it’s actually possible to call most or all of the functions. (Yes DRK, you can now go do XML binding.) But sure, it’d be nice to make a real .NET-ish layer.
Async events seems like it wouldn’t be hard, assuming FreeSWITCH delivers them that way?
-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 Michael Jerris
Sent: Thursday, September 24, 2009 10:26 PM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
There are a few other things I can think would be nice additions to mod_managed. Maybe an event handler that does not require a thread to be sitting and waiting for events trying in a loop would be nice, instead something that is triggered each time there is a certain event class triggered. Also, there has been some interest in doing full endpoint modules in mod_managed. exposing all the state handlers in .net like ways and having that all work would be quite interesting, but probably requires someone specific actually ready to write a module like that to be worthwhile.
Mike
On Sep 24, 2009, at 4:01 AM, Michael Giagnocavo wrote:
Great – hopefully we’ll meet on IRC or the conference sometime on Friday. Email me when you’re on.
A few questions I have:
Clarity – I agree with you there, and thanks!
Testability – is this even remotely practical? Looking at our FS code plugins, there’s simply no way any amount of test environment code would get us to anything testable. We make tons of direct P/Invoke calls, and the whole model for what variables are set when, the state machine progression, etc. does not seem like something that we can hope to possibly model right. And it’s subject to many external influences (all the modules you have loaded in FS). Logging is a pretty simple case, sure, we can make it not call FS for testing. But in a real app, it just seems that there are way too many dependencies, no? Maybe others who have apps written can chime in?
Modularity – I agree there are two parts. But, I think they are pretty tightly coupled. The FS interface into unmanaged code is done via unmanaged code and is really clear: App, Api, ApiBackground. The other ways I can think of are FS-specific, such as XML binding interface and so on. But those are things we should just add to the mod_managed core and be done with. I’m thinking maybe we are talking about different things? Can you provide some user stories that we want to cover with a pluggable loader/executor/etc.? Thanks for putting up with me!
-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 Josh Rivers
Sent: Thursday, September 24, 2009 12:32 AM
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
On Wed, Sep 23, 2009 at 7:31 PM, Michael Giagnocavo <mgg@giagnocavo.net (mgg@giagnocavo.net)> wrote:
Right off the bat: there can be tons of cleanup and refactoring, no doubt about that. Much of the current code is to satisfy my needs in production, which it does very well.
The current base doesn't have anything wrong with it for sure, in fact, I learned a good bit about PInvoke. AppDomains, and In-Process Remoting in the last week.
My refactoring had the following goals (in no particular order)
- Testability - I'd really like to see a decent unit test suite on the more module so that we can change it with confidence. Also, it's been drilled into me that a testable design is a good design.
- Clarity - Where possible, I extracted blocks of code that served a particular purpose so that purpose could be self-documenting in the method calls rather than mixed in.
- Modularity - I wanted to make it easy to remove or add alternative behavior to the managed.dll.
Quote: |
I’m a bit hesitant to go too far from the FreeSWITCH core as far as architecture goes. For instance, I’m not quite sure why’d we have our own managed logging subsystem that allows them to plug in other things that aren’t part of FS. Either they should use the FS logging system, or use their own such as log4net. Or perhaps I don’t see why we’d want this behavior.
|
I completely agree, with the following caveats:
1) I'd like to see things testable. It's very hard to do isolation testing with classes making direct calls out to a static Log class that in turn pinvokes out to unmanaged code.
2) I'd like to allow folk to make changes to the default behavior (optimally) without recompiling managed.dll.
One thing at issue here is that there are two principal purposes for managed.dll. The first is to provide an interface into unmanaged code. The second is a module/plugin extensibility framework. The first purpose should absolutely provide the thinnest layer possible. The second purpose is very likely to need a lot of change and adaptation as people come up with development models that they would like to follow in using freeswitch. The extensibility framework should be mostly managed code, coded to interfaces for mock-ability and testabiliy. It should also be able to just push it out of the way and hook your own extensibilty framework in instead.
Quote: |
Going away from the core as far as adding .NET specific features (like look at the static ManagedSession.Originate that takes hangup delegates, or the “nice” wrapper for Log (Write and WeiteLine, with an enum instead of a string) are keeping close to the core, just adding a tiny bit of API cleanup. FreeSWITCH exposes a lot of strings, and while maybe that’s important for some languages, .NET users are going to expect stronger typing. But I don’t think these types of things get people away from FreeSWITCH much.
|
No disagreement here. I would like to see these things made available by interface rather than concrete implementation. It's currently not possible to test a plugin without loading it into FS. That precludes automated testing, and leaves a pretty big round-trip to test a tweak. I'm a sloppy coder too, so I'm always introducing interesting regressions, and that's why I like doing my testing without having to bring up a full process
Quote: |
Things like making a published SOAP interface for FS seem not really related to mod_managed. They can easily be done as 3rd party plugins, or convince the core FS team that exposing via SOAP via mod_managed is the way to go. Also keep in mind that the majority of users are on Linux, so that rules out WCF and some other fun stuff that only works on the CLR – I’d say it all has to work on Mono.
|
This kind of stuff is definitely beyond the scope of mod_managed. Although there is a slippery slope since we're building in an extensibility model. I don't think a WCF host, or a winforms host, or any of that should be baked in. Rather, I think we should provide the hooks for adding such a thing. If somebody wants to build ESL via WCF, why should they need to leave managed code? If the module system is general enough, then such a thing should just be a module.
(BTW, I think WCF-Mono is getting there http://www.mono-project.com/WCF_Development)
Absolutely, everything in mod_managed and managed.dll should run on mono and the CLR. However, there shouldn't be any reason that a Win-only developer can't build a complete FS application framework that plugs in and only runs on Windows.
Quote: |
As for all the rest of it, can we talk interactively, perhaps with other users interested in mod_managed? Reading over your email, I think I’m not understanding many of the use cases that are being fixed.
|
I'd be very glad to get a discussion going. I definitely haven't covered all of the issues here.
-Josh
_______________________________________________
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
|