![]() |
![]()
| ![]() |
![]()
NAMEAsterisk::FastAGI - Module for FastAGI handling.SYNOPSISuse base 'Asterisk::FastAGI'; sub fastagi_handler { my $self = shift; my $param = $self->param('foo'); my $callerid = $self->input('calleridname'); $self->agi->say_number(1000); } DESCRIPTIONAsterisk::FastAGI provides a preforking daemon for handling FastAGI requests from Asterisk.Read the Net::Server for more information about the logging facilities, configuration, etc. USAGE EXAMPLEFirst you need a module containing all of your AGI handlers.package MyAGI; use base 'Asterisk::FastAGI'; sub agi_handler { my $self = shift; $self->agi->say_number(8675309); } Then you simply need to have a script that runs the daemon. #!/usr/bin/perl use MyAGI; MyAGI->run(); When it is run it creates a preforking daemon on port '4573'. That is the default port for FastAGI. Read the Net::Server documentation on how to change this and many other options. METHODSparamReturns parsed parameters sent in from the AGI script.Inside extensions.conf: exten => 1111,1,Agi(agi://${SERVER}/fastagi_handler?foo=bar&blam=blah You can access those parameters from inside your AGI script. Much like you would if those were URL parameters on a CGI script. my $foo = $self->param('foo'); inputReturns a hash containing the input from the AGI script.my %hash = $self->input() If given a key. It will return that particular value. my $uniqueid = $self->input('uniqueid'); agiWill return the Asterisk::AGI object.process_requestThis will process the agi request from asterisk.dispatch_requestMethod used to dispatch the FastAGI request.child_init_hookThis is called by Net::Server during child initialization. This is the method to override if you are going to be creating database connections for instance.sub child_init_hook { my $self = shift; $self->{server}{dbi} = DBI->connect(); } SEE ALSONet::Server, <http://asterisk.gnuinter.net/>AUTHORJason Yates <jaywhy@gmail.com>COPYRIGHT AND LICENSECopyright (C) 2006-2007 by Jason YatesThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
|