[asterisk-dev] Including external C++ Module

Matthew Nicholson mnicholson at digium.com
Fri Jun 30 10:42:09 MST 2006


Abdul Lateef Khan wrote:
> Hi all,
> 
> Already i posted one question in one forum, could you please guys
> reply my questions, actually i did not post here because in forum i
> found some user friendly to describe as a code etc...
> 
> 
> http://go4calls.com/viewtopic.php?t=21
> 
> Thank You

--- Original Post ---
 > Hi All,
 >
 > I want to include my own application in Asterisk Realtime. for the
 > reasion of routing and calculating call rate.
 >
 > I want to use Asterisk to work as Proxy Server, only for user
 > registeration and routing calls to the carrier via IP Address. I will
 > not use for any PSTN purpose.
 >
 > I written my perl script to do my requirment via GAI Perl. But day by
 > day my cuncurrent calls are increasing so some time our perl script
 > taking more time to connect MySQL and calculatiing balance.
 >
 > Code:
 >
 > [main-ext]
 > exten => _x.,1,Set(UserN=${ACCOUNTCODE})
 > exten => _x.,2,Set(CalledNum=${EXTEN})
 > exten => _x.,3,Set(Stime=${DATETIME})
 > exten => _x.,4,Set(CID=${CALLERID})
 > exten => _x.,5,Set(HCA=${HANGUPCAUSE})
 > exten => _x.,6,Set(Cun=${UNIQUEID})
 > exten => _x.,7,AGI(dial_num.pl)
 > exten => h,1,DeadAGI(/var/lib/asterisk/agi-bin/update_balance.pl)
 >
 >
 >
 > Code:
 > dial_num.pl
 >
 >
 > Inside this file i am calculating the the called country rate
 > according to user balance after that i am dialing from the same file
 > with timelimit.
 >
 > Code:
 >
 > update_balance.pl
 >
 >
 > Once the AGI will dead this script will update the balance and
 > calculate the call rate etc...
 >
 > So this file i compile successfully in C++, now i want to include it
 > in RealTime. because i found C++ is faster than Perl and it will solve
 > my poblem for crashing Database Server.
 >
 >
 > My question is: How i can add my modules before dialing the numbe,
 > Please provide me if there any document?
 >
 > Thank You
 > Khan

There is an API for interacting with Asterisk's realtime framework, if 
it is documented you can generate the documents by running make progdoc. 
  If it is not documented, look at existing code for examples on how it 
works.

If you simply wrote an AGI script in C++ you can use it just like you 
were using your perl script.  You can write asterisk modules in C++ you 
just must be mindful of linkage issues and make proper use of the 
'extern "C"' construct.

You may also want to look into FastAGI to address your performance issues.

-- 
Matthew Nicholson
Digium



More information about the asterisk-dev mailing list