Book Image

FreeSWITCH Cookbook

Book Image

FreeSWITCH Cookbook

Overview of this book

FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice, chat, and video applications. It can scale from a soft-phone to a PBX and even up to an enterprise-class softswitch.In the FreeSWITCH Cookbook, members of the FreeSWITCH development team share some of their hard-earned knowledge with you in the book's recipes. Use this knowledge to improve and expand your FreeSWITCH installations.The FreeSWITCH Cookbook is an essential addition to any VoIP administrator's library.The book starts with recipes on how to handle call routing and then discusses connecting your FreeSWITCH server to the outside world.It then teaches you more advanced topics like CDR handling, practical examples of controlling FreeSWITCH with the event socket, and configuring many features commonly associated with a PBX installation.
Table of Contents (12 chapters)
FreeSWITCH Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Establishing an inbound event socket connection


An "inbound" event socket connection means that an external script or program is connecting to a FreeSWITCH server. The connection is inbound from the server's point of view. In fact, every time you run the fs_cli utility you are making an inbound event socket connection.

Getting ready

Be sure that you have installed ESL for your preferred programming language. (See the previous recipe, Setting up the event socket library.) From there you will just need a text editor, command-line access, and a phone registered to your system. The examples presented here are in Perl, however the accompanying code samples have corresponding examples in Python as well.

How to do it...

The following code is a simple inbound connection that sends the status command to FreeSWITCH. Add the code as follows:

  1. Open scripts/ib_api.pl in a text editor and add these lines:

    #!/usr/bin/perl 
    use strict; 
    use warnings; 
    require ESL; 
    
    my $host = "localhost"; 
    my $port = "8021...