官术网_书友最值得收藏!

Internal calls

Calling local extensions is very simple once you know what needs to happen. In this case, we will review how to add a new user and make his or her phone available to be called.

Getting ready

If you are using the default configuration, then users 1000 through 1019 are pre-configured, both in the directory and the dialplan. To create a user outside this range, it is generally easiest to just run the add_user script, found in the FreeSWITCH source directory under scripts/perl. For example, to add the user 1020, launch this script from the FreeSWITCH source directory, specifying the user ID on the command line:

scripts/perl/add_user 1020

You can also specify a range of users:

scripts/perl/add_user –-users=1020-1029

You will see a note about how many users were added. If you have the CPAN module Regexp::Assembly installed, then the script will also generate a 'sample regular expression pattern'. For our example, we will add a range of users 1020-1029.

How to do it...

Follow these steps:

  1. Open the file conf/dialplan/default.xml in a text editor. Locate the Local_Extension entry:
    <extension name="Local_Extension">
      <condition field="destination_number"expression="^(10[01][09])$">
      ...
  2. Edit the expression in the <condition> tag to account for our new users. The expression pattern ^(10[012][0-9])$ will do what we need (look closely to see the difference). The new line will be as follows:
    <condition field="destination_number" expression="^(10[012][09])$">
  3. Save the file and then execute reloadxml from the fs_cli.

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

How it works...

The Local_Extension is the default dialplan entry that allows directory users to be called. Remember, simply adding a user to the directory does not mean that the user can be dialed. (It does, though, usually mean that the user can make outbound calls.) So in order for your new user to be reachable, you need to add his or her user ID to the dialplan. By default, Local_Extension has a regular expression that will match 1000, 1001, … 1019. When adding users outside that number range, it is necessary to modify the regular expression to account for those new numbers. In our example, we added user IDs 1020 through 1029, so we need to match those. We use this regular expression:

^(10[012][0-9])$

This matches 1000 through 1029. Let's say we added another block of user IDs with the range of 1030 through 1039. We could modify our regular expression to catch those as well:

^(10[0123][0-9])$

It is considered a best practice not to add a large range of dialable numbers in the Local_Extension without having the corresponding users in the directory. Doing so can make troubleshooting dialplan issues more difficult.

As a reminder, be sure to execute the reloadxml command each time you modify the regular expression (the changes you make to your XML configuration files will not take effect until they are loaded into memory, which is what reloadxml command does).

See also

  • The Creating Users section in Chapter 5, PBX Functionality
主站蜘蛛池模板: 阿图什市| 文化| 大埔县| 宁津县| 上饶市| 瓦房店市| 宣化县| 枣强县| 合作市| 嵩明县| 马山县| 湄潭县| 宁陵县| 从化市| 临汾市| 淮滨县| 三穗县| 怀安县| 蓝山县| 大同县| 奈曼旗| 威信县| 剑河县| 合江县| 康乐县| 曲麻莱县| 兖州市| 台湾省| 桂阳县| 莱西市| 缙云县| 宜春市| 涞源县| 柯坪县| 宜宾县| 通许县| 青铜峡市| 武山县| 平凉市| 会东县| 德化县|