The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Asterisk::FastAGI - Module for FastAGI handling.

SYNOPSIS

  use base 'Asterisk::FastAGI';

  sub fastagi_handler {
    my $self = shift;

    my $param = $self->param('foo');
    my $callerid = $self->input('calleridname');

    $self->agi->say_number(1000);
  }

DESCRIPTION

Asterisk::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 EXAMPLE

First 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.

METHODS

param

Returns 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');

input

Returns 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');

agi

Will return the Asterisk::AGI object.

process_request

This will process the agi request from asterisk.

dispatch_request

Method used to dispatch the FastAGI request.

child_init_hook

This 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 ALSO

Net::Server, http://asterisk.gnuinter.net/

AUTHOR

Jason Yates <jaywhy@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2006-2007 by Jason Yates

This 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.