FreeSWITCH Cookbook
上QQ阅读APP看书,第一时间看更新

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 or edit 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/sip/userB@local.pbx.com"/> 
  </condition>
</extension>

How it works...

Putting comma-separated endpoints in the argument to bridge causes all of 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 media first. This includes early media (ringing). To put this another way, if you bridge a call to two parties and one party starts sending a ringing signal back to you, that may be considered media and the call will be connected to that party only. Ringing of the other phones will cease.

If you find 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, 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/sip/userB@local.pbx.com"/>

In this example, userA's phone would ring for a maximum of 20 seconds while userB's phone would ring for a maximum of 30 seconds.

Tip

Call legs and the leg_timeout variable

The leg_timeout variable is unique in 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 complete discussion of using { and } (curly braces) versus [ and ] (square brackets), see http://wiki.freeswitch.org/wiki/Channel_Variables#Channel_Variables_in_Dial_strings.

This method of calling multiple parties works well for small numbers 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 online at http://wiki.freeswitch.org/wiki/Mod_fifo). See also Ringing multiple endpoints sequentially (simple failover) for an example of ringing a group of endpoints one at a time, which includes an expanded discussion of using call timeouts.

See also

  • The Ringing multiple endpoints sequentially (simple failover) section that follows