Freeswitch dialplan written in Perl

Source: Internet
Author: User
Tags perl script freeswitch

I have created a freeswitch kernel research and exchange group, 45211986. welcome to join us. In addition, we provide the SIP-based communication server and client solution to develop the SIP/IMS video client, supports access to the SIP Softswitch, IMS core network, voice, video, and instant communication functions, and video formats such as h263, h264, and MPEG4
Soft encoding soft decoding: provides hardware codec interface connection, and provides servers. If you are interested, contact me.

Freeswtich supports compiling dialplan in Lua, Perl, PHP and other script languages, similar to AGI in Asterisk. But freeswitch is more lightweight, and its XML format dialplan handwriting is indeed troublesome. mod_perl is implemented

Perl writes dialplan interfaces, that is, we can use Perl to call the APIS provided by freeswich to write our own business logic, especially when you want

Introducing business-related data in dialplan, such as querying databases and interacting with third-party business platforms (such as JSON and XML formats) is a good choice to use Perl.

Method:

1. Call the Perl script in XML dialplan

Create the dialplan/default/demo_perl.pl file.

Content:

When the call number is 4001, this process is executed. The function is to play a voice file to the user, then verify the settings and obtain the channel variable API.

 <include><extension name="perl_demo">      <condition field="destination_number" expression="^4001$">          <action application="answer"/>          <action application="perl" data="demo_perl.pl" />      </condition></extension></include>

APP Perl provides mod_perl APIs and executes demo_perl.pl scripts.

The content of this file is as follows:

#!/usr/bin/perluse strict;our $session;freeswitch::console_log("info", "Perl dialplan demo\n");my ($string) = @_;#print "\n\n".Dumper(\@_)."\n\n";my $id = $session->get_uuid();freeswitch::console_log("info", " uuid $id\n");#### set and get variable$session->setVariable("lidp_name", "lidp");my $name = $session->getVariable("lidp_name");freeswitch::console_log("info", " lidp_name = $name\n");$session->execute("playback", "/var/lib/asterisk/moh/macroform-cold_day.wav");$session->hangup();return 1;

If you want to know the functions provided by mod_perl, you can use this command to list them:

grep -o -P "^(\*[^=]+|############# Class.+)" freeswitch.pm

....

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.