<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Given the similarity in purpose, I would look closely at how mod_nibblebill interfaces with freeswitch. &nbsp;It sounds like your interface needs are nearly identical.<div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 5, 2015, at 9:23 AM, Juan Pablo L. &lt;<a href="mailto:jpablolorenzetti@hotmail.com" class="">jpablolorenzetti@hotmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Calibri; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Thank you very much guys for your contributions.<br class=""><br class="">I m doing it as a module for couple of reasons, being the<br class="">most important (i believe) performance, because the module<br class="">i m working on is to do real time charging of voice calls on a switch<br class="">that is already&nbsp; serving as a RBT service plus a bunch of IVR's to purchase<br class="">services, this is for a ~150K user base on a single machine (cold standby)<br class="">this switch is also scheduled to soon start providing hosted PBX services,<span class="Apple-converted-space">&nbsp;</span><br class="">so going the script direction<br class="">i personally dont see that as an option at all. I do use scripts for small no so much used<br class="">much simpler stuff though, e.g: a lua script takes care of authenticating users<br class="">when doing international calls from company extensions in the hosted PBX solution.<br class=""><br class="">The other reason i chose to do<br class="">this as a module because C is the language i feel more comfortable with.<span class="Apple-converted-space">&nbsp;</span><br class="">i hope this clarifies i little bit this.<br class=""><br class="">Moving on, right now i m developing on a test freeswitch that we have and yes i noticed<br class="">that subscribing to the CS_INIT event does represent a big problem<br class="">because i get notified for every single of those events that is generated on<br class="">freeswitch which would be very inconvenient because as i mentioned, the same<br class="">switch does many other things that i m not interested in, so i m going to try the advise<br class="">provided and try to do it in the dial plan, i will explore this option.<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">thank you very much all!<br class=""><br class=""><br class=""><br class=""><br class=""><br class=""><div class="">&gt; Date: Thu, 5 Mar 2015 14:19:51 +0100<br class="">&gt; From:<span class="Apple-converted-space">&nbsp;</span><a href="mailto:ssinyagin@gmail.com" class="">ssinyagin@gmail.com</a><br class="">&gt; To:<span class="Apple-converted-space">&nbsp;</span><a href="mailto:freeswitch-users@lists.freeswitch.org" class="">freeswitch-users@lists.freeswitch.org</a><br class="">&gt; Subject: Re: [Freeswitch-users] sessions and CS_INIT events<br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; but for the task that OP has described, writing (and maintaining it in<br class="">&gt; the long term) a module is really an overkill. Plus, he would also<br class="">&gt; need to take care of multithreading within FreeSWITCH, as well as<br class="">&gt; memory management, etc.<br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; Also, a module makes sense if it's some common task which can be<br class="">&gt; re-used by others and published as open source. If it's some<br class="">&gt; closed-source module for a specific enterprise task that Juan has, it<br class="">&gt; just doesn't make sense and too much risk for a long-term solution.<br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; On Thu, Mar 5, 2015 at 1:56 PM, Vik Killa &lt;<a href="mailto:vipkilla@gmail.com" class="">vipkilla@gmail.com</a>&gt; wrote:<br class="">&gt; &gt; It all depends on what you are trying to do with your module.<br class="">&gt; &gt; You can use a dialplan handler in your module (see mod_enum for example) to<br class="">&gt; &gt; route inbound calls using your custom dialplan.<br class="">&gt; &gt; You can use a state handler in your module and bind to channel states (much<br class="">&gt; &gt; like binding to events).<br class="">&gt; &gt; You can create a dialplan app in your module to execute code when the app is<br class="">&gt; &gt; called in dialplan<br class="">&gt; &gt; (Example: &lt;application action="mycustom_module" data="${uuid} arg1 arg2"/&gt;)<br class="">&gt; &gt; You can use an endpoint in your module to originate calls outbound (see<br class="">&gt; &gt; mod_lcr or mod_callcenter for an example)<br class="">&gt; &gt; Also, you can create an API for your module<br class="">&gt; &gt;<br class="">&gt; &gt; IMO creating a module is much more powerful than using a script with ESL.<br class="">&gt; &gt; But if you are going to create a module, you really don't need to mess with<br class="">&gt; &gt; events (unless they are very specific events like CUSTOM::) because your<br class="">&gt; &gt; module has access to much of the freeswitch core.<br class="">&gt; &gt;<br class="">&gt; &gt; Thanks.<br class="">&gt; &gt;<br class="">&gt; &gt;<br class="">&gt; &gt;<br class="">&gt; &gt; On Thu, Mar 5, 2015 at 5:07 AM, Stanislav Sinyagin &lt;<a href="mailto:ssinyagin@gmail.com" class="">ssinyagin@gmail.com</a>&gt;<br class="">&gt; &gt; wrote:<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; why at all do you need it to be a C module inside FreeSWITCH?<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; Why not writing an ESL program which would subscribe to events and<br class="">&gt; &gt;&gt; perform the needed actions?<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; How about the following scenario:<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; 1. In the XML dialplan, you execute "park" application on the incoming<br class="">&gt; &gt;&gt; call.<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; 2. Your program is listening to events via ESL, and it recognizes that<br class="">&gt; &gt;&gt; a channel has been parked<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; 3. Your program starts to playback the ringback tone into that channel<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; 4. Your program performs all the needed lookups and sets needed<br class="">&gt; &gt;&gt; variables on the channel<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; 5. Your program transfers or bridges the call where needed.<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; This is quite easy to implement in any programming language of your<br class="">&gt; &gt;&gt; choice, easy to debug, and it's easily scalable. It can be done in a<br class="">&gt; &gt;&gt; multi-threading fashion, like Go or Erlang, or even Java, and perform<br class="">&gt; &gt;&gt; as many parallel calls as required.<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; quite easy, and you don't have to mess with FreeSWITCH internals :)<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt;<br class="">&gt; &gt;&gt; On Thu, Mar 5, 2015 at 4:07 AM, Juan Pablo L.<br class="">&gt; &gt;&gt; &lt;<a href="mailto:jpablolorenzetti@hotmail.com" class="">jpablolorenzetti@hotmail.com</a>&gt; wrote:<br class="">&gt; &gt;&gt; &gt; Hi, i m writing a module in C that needs to check for certain<br class="">&gt; &gt;&gt; &gt; information in<br class="">&gt; &gt;&gt; &gt; a<br class="">&gt; &gt;&gt; &gt; database for the caller and the destination number,<br class="">&gt; &gt;&gt; &gt; for this the module is subscribing to the CS_INIT channel events, so<br class="">&gt; &gt;&gt; &gt; everytime a channel is created<br class="">&gt; &gt;&gt; &gt; the module callback is called and it checks the numbers,<br class="">&gt; &gt;&gt; &gt; the problem is that the callback gets called twice,<br class="">&gt; &gt;&gt; &gt; for the creation of the a-leg of the call and the creation of the b-leg.<br class="">&gt; &gt;&gt; &gt; Is there any way to accomplish what i m trying to do ?<br class="">&gt; &gt;&gt; &gt; Am i doing it the wrong way?<br class="">&gt; &gt;&gt; &gt; I have already try getting testing for the flags in the channel but it<br class="">&gt; &gt;&gt; &gt; did<br class="">&gt; &gt;&gt; &gt; not work,<br class="">&gt; &gt;&gt; &gt; testing of originator or originating does not yield anything ....<br class="">&gt; &gt;&gt; &gt;<br class="">&gt; &gt;&gt; &gt; i might be doing it wrong maybe ?<br class="">&gt; &gt;&gt; &gt;<br class="">&gt; &gt;&gt; &gt; Thanks!<br class="">&gt; &gt;&gt; &gt;</div></div></div></blockquote></div></div></body></html>