- FreeSWITCH Cookbook
- Anthony Minessale Darren Schreiber Michael S Collins Raymond Chandler
- 516字
- 2021-08-20 15:44:34
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:
- Open the file
conf/dialplan/default.xml
in a text editor. Locate theLocal_Extension
entry:<extension name="Local_Extension"> <condition field="destination_number"expression="^(10[01][09])$"> ...
- 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])$">
- Save the file and then execute
reloadxml
from thefs_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
- Aftershot Pro:Non-destructive photo editing and management
- 觸摸屏實用技術與工程應用
- Android NDK Game Development Cookbook
- Effective STL中文版:50條有效使用STL的經驗(雙色)
- Deep Learning with PyTorch
- 硬件產品經理成長手記(全彩)
- 硬件產品經理手冊:手把手構建智能硬件產品
- Manage Partitions with GParted How-to
- Spring Cloud微服務架構實戰
- 深入理解序列化與反序列化
- Spring Cloud實戰
- 電腦橫機使用與維修
- Intel FPGA權威設計指南:基于Quartus Prime Pro 19集成開發環境
- 單片機項目設計教程
- 計算機組裝與維護