mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 06:48:25 +00:00
Give Busy() and Congestion() an optional timeout
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3408 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
24
pbx.c
24
pbx.c
@@ -215,13 +215,15 @@ static struct pbx_builtin {
|
|||||||
|
|
||||||
{ "Busy", pbx_builtin_busy,
|
{ "Busy", pbx_builtin_busy,
|
||||||
"Indicate busy condition and stop",
|
"Indicate busy condition and stop",
|
||||||
" Busy(): Requests that the channel indicate busy condition and then waits\n"
|
" Busy([timeout]): Requests that the channel indicate busy condition and\n"
|
||||||
"for the user to hang up. Always returns -1." },
|
"then waits for the user to hang up or the optional timeout to expire.\n"
|
||||||
|
"Always returns -1." },
|
||||||
|
|
||||||
{ "Congestion", pbx_builtin_congestion,
|
{ "Congestion", pbx_builtin_congestion,
|
||||||
"Indicate congestion and stop",
|
"Indicate congestion and stop",
|
||||||
" Congestion(): Requests that the channel indicate congestion and then\n"
|
" Congestion([timeout]): Requests that the channel indicate congestion\n"
|
||||||
"waits for the user to hang up. Always returns -1." },
|
"and then waits for the user to hang up or for the optional timeout to\n"
|
||||||
|
"expire. Always returns -1." },
|
||||||
|
|
||||||
{ "DigitTimeout", pbx_builtin_dtimeout,
|
{ "DigitTimeout", pbx_builtin_dtimeout,
|
||||||
"Set maximum timeout between digits",
|
"Set maximum timeout between digits",
|
||||||
@@ -4209,11 +4211,17 @@ void ast_context_destroy(struct ast_context *con, char *registrar)
|
|||||||
__ast_context_destroy(con,registrar);
|
__ast_context_destroy(con,registrar);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wait_for_hangup(struct ast_channel *chan)
|
static void wait_for_hangup(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct ast_frame *f;
|
struct ast_frame *f;
|
||||||
do {
|
int waittime;
|
||||||
|
|
||||||
|
if (!data || !strlen(data) || (sscanf(data, "%i", &waittime) != 1) || (waittime < 0))
|
||||||
|
waittime = -1;
|
||||||
|
if (waittime > -1) {
|
||||||
|
ast_safe_sleep(chan, waittime * 1000);
|
||||||
|
} else do {
|
||||||
res = ast_waitfor(chan, -1);
|
res = ast_waitfor(chan, -1);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return;
|
return;
|
||||||
@@ -4238,14 +4246,14 @@ static int pbx_builtin_ringing(struct ast_channel *chan, void *data)
|
|||||||
static int pbx_builtin_busy(struct ast_channel *chan, void *data)
|
static int pbx_builtin_busy(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
ast_indicate(chan, AST_CONTROL_BUSY);
|
ast_indicate(chan, AST_CONTROL_BUSY);
|
||||||
wait_for_hangup(chan);
|
wait_for_hangup(chan, data);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pbx_builtin_congestion(struct ast_channel *chan, void *data)
|
static int pbx_builtin_congestion(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
ast_indicate(chan, AST_CONTROL_CONGESTION);
|
ast_indicate(chan, AST_CONTROL_CONGESTION);
|
||||||
wait_for_hangup(chan);
|
wait_for_hangup(chan, data);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user