Ringing multiple endpoints simultaneously
FreeSWITCH makes it easy to ring multiple endpoints simultaneously within a single command.
Getting ready
Open conf/dialplan/default.xml
in a text editor or create a new XML file in the conf/dialplan/default/
subdirectory.
How to do it...
Add a comma-separated list of endpoints to your bridge
(or originate
) application. For example, to ring userA@local.pbx.com
and userB@local.pbx.com
simultaneously, use an extension like this:
<extension name="ring_simultaneously">
<condition field="destination_number" expression="^(2000)$">
<action application="bridge" data="{ignore_early_media=true}sofia/internal/userA@local.pbx.com,sofia/internal/userB@local.pbx.com"/>
</condition>
</extension>
How it works...
Putting comma-separated endpoints into the argument to bridge
causes all the endpoints in that list to be dialed simultaneously. It sounds simple; however, there are several factors to consider when ringing multiple devices simultaneously in a real environment. The bridge
application will connect the call to whoever sends the media first. This includes early media (ringing). To put this in other words, if you bridge a call to two parties and one party starts sending a ringing signal back to you, that will be considered media and the call will be connected to that party. Ringing of the other phones will cease.
If you notice that calls always go to a specific number on your list of endpoints versus ringing all numbers, or that all phones ring for a moment before ringing only a single number, it means that your call may be getting bridged prematurely because of early media. Notice that we added ignore_early_media=true
at the beginning of the dial string. As its name implies, ignore_early_media
tells the bridge
application not to connect the calling party to the called party when receiving early media (such as a ringing or busy signal). Instead, bridge
will only connect the calling party to the called party who actually answers the call. In most cases, it is useful to ignore early media when ringing multiple endpoints simultaneously.
There's more...
In some scenarios, you may also wish to ring specific devices for a limited amount of time. You can apply the leg_timeout
parameter to each leg of the bridge to specify how long to ring each endpoint like this:
<action application="bridge" data="[leg_timeout=20]sofia/internal/userA@local.pbx.com,[leg_timeout=30]sofia/internal/userB@local.pbx.com"/>
In this example, the userA
user's phone will ring for a maximum of 20 seconds, while the userB
user's phone will ring for a maximum of 30 seconds.
Tip
Call legs and the leg_timeout variable
The leg_timeout
variable is unique in the sense that it implies the ignoring of early media. When using the leg_timeout
variable on each call leg in a bridge
attempt, there is no need to explicitly use {ignore_early_media=true}
in the bridge
argument. For a more thorough discussion of using {
and }
(curly brackets) versus [
and ]
(square brackets), see http://freeswitch.org/confluence/display/FREESWITCH/Channel+Variables#ChannelVariables-ChannelVariablesinDialstrings.
This method of calling multiple parties works well for a small number of endpoints. However, it does not scale to dozens or more users. Consider using a FIFO queue in such an environment (FreeSWITCH's mod_fifo
is discussed at length at http://freeswitch.org/confluence/display/FREESWITCH/mod_fifo).
See also
- The Ringing multiple endpoints sequentially (simple failover) recipe that follows for an example of ringing a group of endpoints one at a time, which includes an expanded discussion of using call timeouts