O'Reilly Emerging Telephony

oreilly.comSafari Books Online.Conferences.
advertisement
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA
AddThis Social Bookmark Button

Listen Print Discuss Subscribe to Telephony Subscribe to Newsletters

Sophisticated Asterisk Development with Adhearsion

by Jay Phillips
06/19/2007

Editor's Note: Jay Phillips is the creator of Adhearsion and has written a section about the open source Ruby framework for the upcoming second edition of Asterisk: The Future of Telephony. We're proud to present this expanded excerpt of Jay's material here on ETel. The newly updated version of O'Reilly's best-selling Asterisk book is available now as a Rough Cut.

As Asterisk has matured, both in technological innovation and in appealing to the masses, the subject of programming complex, enterprise-grade logic with Asterisk alone remains unsolved. The web interface in version 1.4 constitutes an enormous leap forward for the deployment of Asterisk in small businesses where the usage pattern is predictable. Small businesses need an easily managed PBX that reduces monthly phone costs, and Asterisk fits the ticket well.

Beyond the predictable, however, the GUI and even Asterisk's internal extensions.conf and AEL grammars break down. They commonly do not account for the sophisticated uses to which the rest of the software industry has grown accustomed. Having a relatively limited toolbox of functions and little development pattern optimization, these grammars remind us of the embedded assembler languages beyond which most server software developers have matured.

Common pain-points in Asterisk dial plan authoring include:

  • Conditional looping and branching
  • Variables
  • Complex data structures
  • Database/LDAP integration
  • Use of third-party libraries
  • Exchanging and distributing VoIP functionality
  • Extending the configuration languages
  • Poor error handling
  • Poor date and time handling
  • Pattern matching
  • Usage consistency
  • Source code organization

Supporting higher-level concepts implies the use of a language both with internal support for these criteria and an extensive existing code base with which applications can be written. Aiming to solve this issue, Adhearsion arose with a new approach.

Asterisk Development with Adhearsion

Adhearsion is an open source (LGPL) framework that, in simplest terms, improves Asterisk development. It rests above an Asterisk system, handling parts or all of the dial plan and, in a few unique ways, manages access to Asterisk with several improved interfaces. Because it runs as a separate daemon process and integrates through the already present Gateway (AGI) and Manager (AMI) interfaces, configuring a context to use Adhearsion is as simple as adding a few lines to your dial plan or adding a user to manager.conf.

Adhearsion primarily uses the highly dynamic, object-oriented Ruby programming language with optional support for other languages such as C or Java. In the VoIP world, many things simply do exist as conceptual objects, making object-oriented programming here particularly comfortable. Scripting languages per se also improve developer productivity by removing tedium such as recompiling, memory management, strict data types, and other extraneous formalities. Those familiar with Python, Perl, or other scripting languages should have no trouble picking up another similar scripting language like Ruby.

Installing Adhearsion

Ruby software is generally installed through Ruby's package manager, an analog to Linux package managers but for the Ruby platform exclusively. Adhearsion exists as a gem in the standard RubyGems trove so, with Ruby and RubyGems installed, Adhearsion is only one install command away.

Installing Ruby/RubyGems on AsteriskNOW

AsteriskNOW comes standard with Ruby but not RubyGems (for support reasons). Thankfully, RubyGems can be easily installed from the Ruby rPath trove with the following command:

conary update rubygems=ruby.rpath.org@rpl:devel
source /etc/profile

Installing Ruby/RubyGems on Linux

Most Linux distributions' package managers host a Ruby package, though some oddly do not have RubyGems. With your respective distro's preferred software management application, install Ruby 1.8.5 or later and RubyGems if available. If RubyGems is not available, it can be easily downloaded and installed from http://rubyforge.org/projects/rubygems.

Installing Ruby/RubyGems on Mac OS X

Ruby actually ships standard with OS X, but you will need to upgrade it and install RubyGems from MacPorts, an OS X package manager. With MacPorts installed (available from http://www.macports.org if you do not already have it) you can install Ruby and RubyGems with the following command:

sudo port install ruby rb-rubygems

You may also need to add /opt/local/bin to your PATH variable in /etc/profile.

Pages: 1, 2, 3, 4

Next Pagearrow




Search Emerging Telephony

Search

Tagged Articles

Be the first to post this article to del.icio.us

Sponsored Resources

  • Inside Lightroom

Related to this Article

Take Control of Your iPhone Take Control of Your iPhone
April 2009
$15.00 USD

Take Control of Your iPhone Take Control of Your iPhone
by Ted Landau
February 2009
$10.00 USD

Advertisement
O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com