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