text stringlengths 0 152 |
|---|
Finally, let’s deliver the finished product. |
exten => 107,1,Dial(Local/owner@localDialDelay) |
;We're going to assign some variables in order to |
;keep the dial string easier to read |
exten => 108,1,Noop(DialDelay) |
same => n,Set(Recpn=Local/receptionist@localDialDelay) |
same => n,Set(Team1=Local/team_one@localDialDelay) |
same => n,Set(Team2=Local/team_two@localDialDelay) |
same => n,Set(Boss=Local/owner@localDialDelay) |
same => n,Dial(${Recpn}&${Team1}&${Team2}&${Boss},600) |
You really need to register a few phones and try this out, to see it all come together. |
Local Channels |
| |
179 |
The solution we have created here is perfect for learning about local channels, but it |
has a few problems that need to be understood if you ever want to put it into |
production: |
• Even though we have set a dial timeout, you will find that SIP endpoints have |
minds of their own. It’s not uncommon for a SIP endpoint to have its own ideas |
about timeout. So, you might set it to ring for 600 seconds, and wonder why it |
drops the call after a minute or so. You could spend hours troubleshooting your |
dialplan, only to discover the problem was a setting at the other end. Test each |
piece of the solution before you glue them all together. |
• Cell phones have their own voicemail, and if that answers the call, Asterisk will |
connect the call to that “answered” channel. One way around this is to hang up |
before that happens, and then call immediately back. It’s ugly though, and not |
recommended. |
• Cell phones will often go immediately to a voicemail if they’re out of range or |
turned off. That counts as an answer as far as Asterisk is concerned. This solution |
does not handle that. |
• Call setup to a cell phone (i.e., the time between when you dial and when it starts |
ringing) typically takes a dozen seconds or so. |
• Remember that a softphone on a cell phone is not at all the same as a phone call |
to that cell phone. One is a SIP connection, the other is a PSTN call. (You can |
actually ring both at the same time if you want, but that’s not necessarily a good |
idea.) |
• Some types of smartphones will give priority to incoming GSM calls. If you are |
on a call on the softphone, and somebody calls your cell number, the softphone |
may get put on hold. Different phones handle this differently. |
• We haven’t really handled overflow here. What happens if nobody answers? It |
doesn’t matter in the lab, but you can be sure it’ll matter in a production environ‐ |
ment. |
• Dial() expects ringing back from the destination. If all of your local channels |
have a Wait() delay, the caller will hear silence until something indicates ringing. |
You can fix this by having Dial() fake the ringing with the 'r' option, or by |
adding a dummy local channel that just returns ringing. |
If you check the sample dialplan, we’ve added a solution to the |
silence problem on delayed local channels |
180 |
| |
Chapter 10: Deeper into the Dialplan |
That’s it. Local channels: build them piece-by-piece and you’ll be delivering a power‐ |
ful dialplan in no time. |
They’re incredibly useful when building complex queueing applications as well. |
Using the Asterisk Database |
Asterisk provides a simple mechanism for storing data called the Asterisk database |
(AstDB). This is not an external relational database, but simply an SQLite-based |
backend for storing simple key/value pairs. |
The Asterisk database stores its data in groupings called families, with values identi‐ |
fied by keys. Within a family, a key may be used only once. For example, if we had a |
family called test, we could store only one value with a key called count. Each stored |
value must be associated with a family. |
Storing Data in the AstDB |
To store a new value in the Asterisk database, we use the Set() application with the |
DB() function. For example, to assign the count key in the test family with the value |
of 1, we would write the following: |
exten => 216,1,NoOp() |
same => n,Set(DB(testkey/count)=1) |
Make a test call to 216 to set the value. Note that if a key named count already exists |
in the test family, its value will be overwritten with the new value (in this case, the |
value is hardcoded so obviously will get overwritten with the same value, but later |
we’ll see how we can change the value, and have that stored). |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.