<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><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&nbsp; 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>&gt; Date: Thu, 5 Mar 2015 14:19:51 +0100<br>&gt; From: ssinyagin@gmail.com<br>&gt; To: freeswitch-users@lists.freeswitch.org<br>&gt; Subject: Re: [Freeswitch-users] sessions and CS_INIT events<br>&gt; <br>&gt; but for the task that OP has described, writing (and maintaining it in<br>&gt; the long term) a module is really an overkill. Plus, he would also<br>&gt; need to take care of multithreading within FreeSWITCH, as well as<br>&gt; memory management, etc.<br>&gt; <br>&gt; Also, a module makes sense if it's some common task which can be<br>&gt; re-used by others and published as open source. If it's some<br>&gt; closed-source module for a specific enterprise task that Juan has, it<br>&gt; just doesn't make sense and too much risk for a long-term solution.<br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt; On Thu, Mar 5, 2015 at 1:56 PM, Vik Killa &lt;vipkilla@gmail.com&gt; wrote:<br>&gt; &gt; It all depends on what you are trying to do with your module.<br>&gt; &gt; You can use a dialplan handler in your module (see mod_enum for example) to<br>&gt; &gt; route inbound calls using your custom dialplan.<br>&gt; &gt; You can use a state handler in your module and bind to channel states (much<br>&gt; &gt; like binding to events).<br>&gt; &gt; You can create a dialplan app in your module to execute code when the app is<br>&gt; &gt; called in dialplan<br>&gt; &gt; (Example: &lt;application action="mycustom_module" data="${uuid} arg1 arg2"/&gt;)<br>&gt; &gt; You can use an endpoint in your module to originate calls outbound (see<br>&gt; &gt; mod_lcr or mod_callcenter for an example)<br>&gt; &gt; Also, you can create an API for your module<br>&gt; &gt;<br>&gt; &gt; IMO creating a module is much more powerful than using a script with ESL.<br>&gt; &gt; But if you are going to create a module, you really don't need to mess with<br>&gt; &gt; events (unless they are very specific events like CUSTOM::) because your<br>&gt; &gt; module has access to much of the freeswitch core.<br>&gt; &gt;<br>&gt; &gt; Thanks.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; On Thu, Mar 5, 2015 at 5:07 AM, Stanislav Sinyagin &lt;ssinyagin@gmail.com&gt;<br>&gt; &gt; wrote:<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; why at all do you need it to be a C module inside FreeSWITCH?<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; Why not writing an ESL program which would subscribe to events and<br>&gt; &gt;&gt; perform the needed actions?<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; How about the following scenario:<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; 1. In the XML dialplan, you execute "park" application on the incoming<br>&gt; &gt;&gt; call.<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; 2. Your program is listening to events via ESL, and it recognizes that<br>&gt; &gt;&gt; a channel has been parked<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; 3. Your program starts to playback the ringback tone into that channel<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; 4. Your program performs all the needed lookups and sets needed<br>&gt; &gt;&gt; variables on the channel<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; 5. Your program transfers or bridges the call where needed.<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; This is quite easy to implement in any programming language of your<br>&gt; &gt;&gt; choice, easy to debug, and it's easily scalable. It can be done in a<br>&gt; &gt;&gt; multi-threading fashion, like Go or Erlang, or even Java, and perform<br>&gt; &gt;&gt; as many parallel calls as required.<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; quite easy, and you don't have to mess with FreeSWITCH internals :)<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; On Thu, Mar 5, 2015 at 4:07 AM, Juan Pablo L.<br>&gt; &gt;&gt; &lt;jpablolorenzetti@hotmail.com&gt; wrote:<br>&gt; &gt;&gt; &gt; Hi, i m writing a module in C that needs to check for certain<br>&gt; &gt;&gt; &gt; information in<br>&gt; &gt;&gt; &gt; a<br>&gt; &gt;&gt; &gt; database for the caller and the destination number,<br>&gt; &gt;&gt; &gt; for this the module is subscribing to the CS_INIT channel events, so<br>&gt; &gt;&gt; &gt; everytime a channel is created<br>&gt; &gt;&gt; &gt; the module callback is called and it checks the numbers,<br>&gt; &gt;&gt; &gt; the problem is that the callback gets called twice,<br>&gt; &gt;&gt; &gt; for the creation of the a-leg of the call and the creation of the b-leg.<br>&gt; &gt;&gt; &gt; Is there any way to accomplish what i m trying to do ?<br>&gt; &gt;&gt; &gt; Am i doing it the wrong way?<br>&gt; &gt;&gt; &gt; I have already try getting testing for the flags in the channel but it<br>&gt; &gt;&gt; &gt; did<br>&gt; &gt;&gt; &gt; not work,<br>&gt; &gt;&gt; &gt; testing of originator or originating does not yield anything ....<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt; i might be doing it wrong maybe ?<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt; Thanks!<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt; _________________________________________________________________________<br>&gt; &gt;&gt; &gt; Professional FreeSWITCH Consulting Services:<br>&gt; &gt;&gt; &gt; consulting@freeswitch.org<br>&gt; &gt;&gt; &gt; http://www.freeswitchsolutions.com<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt; Official FreeSWITCH Sites<br>&gt; &gt;&gt; &gt; http://www.freeswitch.org<br>&gt; &gt;&gt; &gt; http://confluence.freeswitch.org<br>&gt; &gt;&gt; &gt; http://www.cluecon.com<br>&gt; &gt;&gt; &gt;<br>&gt; &gt;&gt; &gt; FreeSWITCH-users mailing list<br>&gt; &gt;&gt; &gt; FreeSWITCH-users@lists.freeswitch.org<br>&gt; &gt;&gt; &gt; http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>&gt; &gt;&gt; &gt; UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>&gt; &gt;&gt; &gt; http://www.freeswitch.org<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; _________________________________________________________________________<br>&gt; &gt;&gt; Professional FreeSWITCH Consulting Services:<br>&gt; &gt;&gt; consulting@freeswitch.org<br>&gt; &gt;&gt; http://www.freeswitchsolutions.com<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; Official FreeSWITCH Sites<br>&gt; &gt;&gt; http://www.freeswitch.org<br>&gt; &gt;&gt; http://confluence.freeswitch.org<br>&gt; &gt;&gt; http://www.cluecon.com<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; FreeSWITCH-users mailing list<br>&gt; &gt;&gt; FreeSWITCH-users@lists.freeswitch.org<br>&gt; &gt;&gt; http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>&gt; &gt;&gt; UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>&gt; &gt;&gt; http://www.freeswitch.org<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; _________________________________________________________________________<br>&gt; &gt; Professional FreeSWITCH Consulting Services:<br>&gt; &gt; consulting@freeswitch.org<br>&gt; &gt; http://www.freeswitchsolutions.com<br>&gt; &gt;<br>&gt; &gt; Official FreeSWITCH Sites<br>&gt; &gt; http://www.freeswitch.org<br>&gt; &gt; http://confluence.freeswitch.org<br>&gt; &gt; http://www.cluecon.com<br>&gt; &gt;<br>&gt; &gt; FreeSWITCH-users mailing list<br>&gt; &gt; FreeSWITCH-users@lists.freeswitch.org<br>&gt; &gt; http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>&gt; &gt; UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>&gt; &gt; http://www.freeswitch.org<br>&gt; <br>&gt; _________________________________________________________________________<br>&gt; Professional FreeSWITCH Consulting Services: <br>&gt; consulting@freeswitch.org<br>&gt; http://www.freeswitchsolutions.com<br>&gt; <br>&gt; Official FreeSWITCH Sites<br>&gt; http://www.freeswitch.org<br>&gt; http://confluence.freeswitch.org<br>&gt; http://www.cluecon.com<br>&gt; <br>&gt; FreeSWITCH-users mailing list<br>&gt; FreeSWITCH-users@lists.freeswitch.org<br>&gt; http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>&gt; UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>&gt; http://www.freeswitch.org<br></div>                                               </div></body>
</html>