Asterisk cmd Wait

Synopsis

Waits for specified time

Description

Wait(seconds)

The Wait command takes one argument, the number of seconds to wait. During the time waited, all sound input received on the channel, including DTMF tones, are silently ignored. The Wait command is typically used before answering a channel, although in newer Asterisk version (1.4 and later) Answer() itself can take an argument in milliseconds to wait for the desired number of seconds.

If the argument is zero or a negative number, Wait does nothing. The argument can be a fractional number like 0.3 or 1.5 .

If Wait() is run on a channel which has been hung up (i.e. from the 'h' extension), the Wait() application returns 0 immediately and no further processing of the 'h' extension priorities takes place. You can get around this with 'System(path/to/sleep Xs)', where 'X' is the number of seconds to wait. Nasty, but it works.

How to Accept DTMF Keypresses While Waiting

The Wait command will ignore any DTMF input from buttons pressed by callers on the line. If you want to accept DTMF input while waiting, set the wait time by calling ResponseTimeout and do not define a step at the next highest priority. Asterisk will silently wait up to ResponseTimeout seconds for the user to dial an extension number valid in the current context.

Notes

June 2010:Wait could be modified to work on a dead channel in extension h, but as it stands right now the code assumes the channel is alive, and to ensure that things work properly, it has to read incoming media from the channel so it can be discarded... and if at any time waiting for or reading media from the channel fails, it exits, because there's no point in continuing to wait since the call is gone.

Example

This example will wait 30 seconds (typically about 6-7 rings) before answering the channel.