Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d6f14d03
提交
d6f14d03
authored
7月 12, 2010
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add fifo_member_usage app
上级
1734df82
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
79 行增加
和
3 行删除
+79
-3
mod_fifo.c
src/mod/applications/mod_fifo/mod_fifo.c
+79
-3
没有找到文件。
src/mod/applications/mod_fifo/mod_fifo.c
浏览文件 @
d6f14d03
...
...
@@ -729,6 +729,7 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
char
*
parsed
=
NULL
;
switch_event_create_brackets
(
h
->
originate_string
,
'{'
,
'}'
,
','
,
&
ovars
,
&
parsed
);
switch_event_del_header
(
ovars
,
"fifo_outbound_uuid"
);
if
(
!
h
->
timeout
)
h
->
timeout
=
60
;
if
(
timeout
<
h
->
timeout
)
timeout
=
h
->
timeout
;
...
...
@@ -1363,6 +1364,46 @@ SWITCH_STANDARD_API(fifo_add_outbound_function)
}
static
switch_status_t
hanguphook
(
switch_core_session_t
*
session
)
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
switch_channel_state_t
state
=
switch_channel_get_state
(
channel
);
const
char
*
uuid
=
NULL
;
char
sql
[
256
]
=
""
;
if
(
state
==
CS_HANGUP
||
state
==
CS_ROUTING
)
{
if
((
uuid
=
switch_channel_get_variable
(
channel
,
"fifo_outbound_uuid"
)))
{
switch_snprintf
(
sql
,
sizeof
(
sql
),
"update fifo_outbound set use_count=use_count-1, "
"outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'"
,
(
long
)
switch_epoch_time_now
(
NULL
),
uuid
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
}
switch_core_event_hook_remove_state_change
(
session
,
hanguphook
);
}
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_STANDARD_APP
(
fifo_member_usage_function
)
{
char
*
sql
;
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
if
(
zstr
(
data
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Invalid!
\n
"
);
return
;
}
switch_channel_set_variable
(
channel
,
"fifo_outbound_uuid"
,
data
);
sql
=
switch_mprintf
(
"update fifo_outbound set use_count=use_count+1,outbound_fail_count=0 where uuid='%s'"
,
data
);
fifo_execute_sql
(
sql
,
globals
.
sql_mutex
);
switch_safe_free
(
sql
);
switch_core_event_hook_add_state_change
(
session
,
hanguphook
);
}
typedef
enum
{
STRAT_MORE_PPL
,
...
...
@@ -2772,6 +2813,26 @@ const char bridge_sql[] =
");
\n
"
;
static
void
extract_fifo_outbound_uuid
(
char
*
string
,
char
*
uuid
,
switch_size_t
len
)
{
switch_event_t
*
ovars
;
char
*
parsed
=
NULL
;
const
char
*
fifo_outbound_uuid
;
switch_event_create
(
&
ovars
,
SWITCH_EVENT_REQUEST_PARAMS
);
switch_event_create_brackets
(
string
,
'{'
,
'}'
,
','
,
&
ovars
,
&
parsed
);
if
((
fifo_outbound_uuid
=
switch_event_get_header
(
ovars
,
"fifo_outbound_uuid"
)))
{
switch_snprintf
(
uuid
,
len
,
"%s"
,
fifo_outbound_uuid
);
}
switch_safe_free
(
parsed
);
switch_event_destroy
(
&
ovars
);
}
static
switch_status_t
load_config
(
int
reload
,
int
del_all
)
{
char
*
cf
=
"fifo.conf"
;
...
...
@@ -2919,8 +2980,13 @@ static switch_status_t load_config(int reload, int del_all)
const
char
*
taking_calls
=
switch_xml_attr_soft
(
member
,
"taking_calls"
);
char
*
name_dup
,
*
p
;
char
digest
[
SWITCH_MD5_DIGEST_STRING_SIZE
]
=
{
0
};
switch_md5_string
(
digest
,
(
void
*
)
member
->
txt
,
strlen
(
member
->
txt
));
if
(
switch_stristr
(
"fifo_outbound_uuid="
,
member
->
txt
))
{
extract_fifo_outbound_uuid
(
member
->
txt
,
digest
,
sizeof
(
digest
));
}
else
{
switch_md5_string
(
digest
,
(
void
*
)
member
->
txt
,
strlen
(
member
->
txt
));
}
if
(
simo
)
{
simo_i
=
atoi
(
simo
);
}
...
...
@@ -3023,7 +3089,11 @@ static void fifo_member_add(char *fifo_name, char *originate_string, int simo_co
char
*
sql
,
*
name_dup
,
*
p
;
fifo_node_t
*
node
=
NULL
;
switch_md5_string
(
digest
,
(
void
*
)
originate_string
,
strlen
(
originate_string
));
if
(
switch_stristr
(
"fifo_outbound_uuid="
,
originate_string
))
{
extract_fifo_outbound_uuid
(
originate_string
,
digest
,
sizeof
(
digest
));
}
else
{
switch_md5_string
(
digest
,
(
void
*
)
originate_string
,
strlen
(
originate_string
));
}
sql
=
switch_mprintf
(
"delete from fifo_outbound where fifo_name='%q' and uuid = '%q'"
,
fifo_name
,
digest
);
switch_assert
(
sql
);
...
...
@@ -3065,7 +3135,11 @@ static void fifo_member_del(char *fifo_name, char *originate_string)
callback_t
cbt
=
{
0
};
fifo_node_t
*
node
=
NULL
;
switch_md5_string
(
digest
,
(
void
*
)
originate_string
,
strlen
(
originate_string
));
if
(
switch_stristr
(
"fifo_outbound_uuid="
,
originate_string
))
{
extract_fifo_outbound_uuid
(
originate_string
,
digest
,
sizeof
(
digest
));
}
else
{
switch_md5_string
(
digest
,
(
void
*
)
originate_string
,
strlen
(
originate_string
));
}
sql
=
switch_mprintf
(
"delete from fifo_outbound where fifo_name='%q' and uuid = '%q' and hostname='%q'"
,
fifo_name
,
digest
,
globals
.
hostname
);
switch_assert
(
sql
);
...
...
@@ -3212,6 +3286,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load)
/* connect my internal structure to the blank pointer passed to me */
*
module_interface
=
switch_loadable_module_create_module_interface
(
pool
,
modname
);
SWITCH_ADD_APP
(
app_interface
,
"fifo"
,
"Park with FIFO"
,
FIFO_DESC
,
fifo_function
,
FIFO_USAGE
,
SAF_NONE
);
SWITCH_ADD_APP
(
app_interface
,
"fifo_member_usage"
,
"increment a member usage until the call ends"
,
""
,
fifo_member_usage_function
,
"<fifo_outbound_uuid>"
,
SAF_NONE
);
SWITCH_ADD_API
(
commands_api_interface
,
"fifo"
,
"Return data about a fifo"
,
fifo_api_function
,
FIFO_API_SYNTAX
);
SWITCH_ADD_API
(
commands_api_interface
,
"fifo_member"
,
"Add members to a fifo"
,
fifo_member_api_function
,
FIFO_MEMBER_API_SYNTAX
);
SWITCH_ADD_API
(
commands_api_interface
,
"fifo_add_outbound"
,
"Add outbound members to a fifo"
,
fifo_add_outbound_function
,
"<node> <url> [<priority>]"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论