Skip to Content
《Asterisk:权威指南》第 5 版
book

《Asterisk:权威指南》第 5 版

by Jim Van Meggelen, Russell Bryant, Leif Madsen
May 2025
Intermediate to advanced
414 pages
5h 2m
Chinese
O'Reilly Media, Inc.
Content preview from 《Asterisk:权威指南》第 5 版

第 6 章 拨号平面基础知识 拨号计划基础知识

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

一切都应尽可能简单,但不能更简单

阿尔伯特-爱因斯坦

拨号计划 是 Asterisk 系统的核心。它定义了呼叫如何进出系统。拨号计划是用脚本语言编写的,脚本语言规定了 Asterisk 在响应来自信道的呼叫时所遵循的指令。与传统电话系统相比,Asterisk 的拨号计划是完全可定制的。

有经验的软件开发人员会发现 Asterisk dialplan 代码已经过时,他们通常更喜欢使用 AMI 和 ARI 等 Asterisk API(我们将在后面的章节中讨论)来控制呼叫流。不管你在这方面有什么打算,如果先了解拨号计划,学习 Asterisk 的行为方式就会容易得多。也许还值得注意的是,Asterisk 的拨号计划经过了性能调整,因此从响应速度和对系统的最小负载来看,它是执行呼叫流的最快方式。拨号计划是快速的。

本章介绍了拨号计划的基本概念,这些概念将成为你编写任何拨号计划的基础。不要跳过本章太多的内容,因为本章的示例是建立在其他示例基础之上的,而且本章对 Asterisk 至关重要。还请注意,本章绝不是对拨号计划所有可能功能的详尽调查;我们的目标只是涵盖基本功能。 我们将在以后的章节中介绍更高级的拨号计划主题。我们鼓励你进行尝试。

拨号计划语法

Asterisk 的拨号计划在配置文件extensions.conf 中指定,该文件位于/etc/asterisk目录中。

拨号计划结构建立在四个分层组件 上:上下文、扩展、优先级和应用程序(见图 6-1)。

图 6-1. 拨号计划层次结构

让我们直接进入主题。

背景

拨号计划 被划分为若干部分,称为上下文 ,用于分隔拨号计划的不同部分。在一个上下文中定义的分机与任何其他上下文中的分机完全隔离,除非特别允许交互。

举个简单的例子,假设有两家公司共用一台 Asterisk 服务器。如果我们把每家公司的自动话务员(IVR)放在自己的上下文中,两家公司就会完全分开。这样,我们就可以独立定义拨打 0 号分机时发生的情况:

  • 从 A 公司语音菜单拨 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho

Publisher Resources

ISBN: 9798341659568