Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
cf0a3bbf
提交
cf0a3bbf
authored
11月 14, 2013
作者:
Chris Rienzo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod_rayo: added args to console aliases
上级
7330b005
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
70 行增加
和
12 行删除
+70
-12
rayo.conf.xml
...ent_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml
+8
-4
mod_rayo.c
src/mod/event_handlers/mod_rayo/mod_rayo.c
+62
-8
没有找到文件。
src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml
浏览文件 @
cf0a3bbf
...
@@ -57,13 +57,16 @@
...
@@ -57,13 +57,16 @@
<!-- IQ request aliases. Used mainly for testing purposes or for controlling a rayo call via the console -->
<!-- IQ request aliases. Used mainly for testing purposes or for controlling a rayo call via the console -->
<aliases>
<aliases>
<alias
name=
"ping"
target=
"external"
>
<![CDATA[<iq type="get"><ping xmlns="urn:xmpp:ping"/></iq>]]>
</alias>
<alias
name=
"ping"
target=
"external"
>
<![CDATA[<iq type="get"><ping xmlns="urn:xmpp:ping"/></iq>]]>
</alias>
<alias
name=
"dial"
target=
"server"
args=
"2"
>
<![CDATA[<dial xmlns="urn:xmpp:rayo:1" from="$1" to="$2"/>]]>
</alias>
<alias
name=
"answer"
target=
"call"
>
<![CDATA[<answer xmlns="urn:xmpp:rayo:1"/>]]>
</alias>
<alias
name=
"answer"
target=
"call"
>
<![CDATA[<answer xmlns="urn:xmpp:rayo:1"/>]]>
</alias>
<alias
name=
"hangup"
target=
"call"
>
<![CDATA[<hangup xmlns="urn:xmpp:rayo:1"/>]]>
</alias>
<alias
name=
"hangup"
target=
"call"
>
<![CDATA[<hangup xmlns="urn:xmpp:rayo:1"/>]]>
</alias>
<alias
name=
"join_mixer_duplex"
target=
"call"
>
<![CDATA[<join xmlns="urn:xmpp:rayo:1" mixer-name="test" direction="duplex"/>]]>
</alias>
<alias
name=
"join"
target=
"call"
args=
"1"
>
<![CDATA[<join xmlns="urn:xmpp:rayo:1" call-uri="xmpp:$1"/>]]>
</alias>
<alias
name=
"join_mixer_send"
target=
"call"
>
<![CDATA[<join xmlns="urn:xmpp:rayo:1" mixer-name="test" direction="send"/>]]>
</alias>
<alias
name=
"join_mixer_duplex"
target=
"call"
args=
"1"
>
<![CDATA[<join xmlns="urn:xmpp:rayo:1" mixer-name="$1" direction="duplex"/>]]>
</alias>
<alias
name=
"join_mixer_recv"
target=
"call"
>
<![CDATA[<join xmlns="urn:xmpp:rayo:1" mixer-name="test" direction="recv"/>]]>
</alias>
<alias
name=
"join_mixer_send"
target=
"call"
args=
"1"
>
<![CDATA[<join xmlns="urn:xmpp:rayo:1" mixer-name="$1" direction="send"/>]]>
</alias>
<alias
name=
"unjoin_mixer"
target=
"call"
>
<![CDATA[<unjoin xmlns="urn:xmpp:rayo:1" mixer-name="test"/>]]>
</alias>
<alias
name=
"join_mixer_recv"
target=
"call"
args=
"1"
>
<![CDATA[<join xmlns="urn:xmpp:rayo:1" mixer-name="$1" direction="recv"/>]]>
</alias>
<alias
name=
"unjoin_mixer"
target=
"call"
args=
"1"
>
<![CDATA[<unjoin xmlns="urn:xmpp:rayo:1" mixer-name="$1"/>]]>
</alias>
<alias
name=
"unjoin"
target=
"call"
>
<![CDATA[<unjoin xmlns="urn:xmpp:rayo:1"/>]]>
</alias>
<alias
name=
"unjoin"
target=
"call"
>
<![CDATA[<unjoin xmlns="urn:xmpp:rayo:1"/>]]>
</alias>
<alias
name=
"unjoin_call"
target=
"call"
args=
"1"
>
<![CDATA[<unjoin xmlns="urn:xmpp:rayo:1" call-uri="xmpp:$1"/>]]>
</alias>
<alias
name=
"stop"
target=
"component"
>
<![CDATA[<stop xmlns="urn:xmpp:rayo:ext:1"/>]]>
</alias>
<alias
name=
"stop"
target=
"component"
>
<![CDATA[<stop xmlns="urn:xmpp:rayo:ext:1"/>]]>
</alias>
<alias
name=
"output_bad"
target=
"call"
>
<![CDATA[<output xmlns="urn:xmpp:rayo:output:1" repeat-time="100"></output>]]>
</alias>
<alias
name=
"output_bad"
target=
"call"
>
<![CDATA[<output xmlns="urn:xmpp:rayo:output:1" repeat-time="100"></output>]]>
</alias>
<alias
name=
"pause"
target=
"output"
>
<![CDATA[<pause xmlns="urn:xmpp:rayo:output:1"/>]]>
</alias>
<alias
name=
"pause"
target=
"output"
>
<![CDATA[<pause xmlns="urn:xmpp:rayo:output:1"/>]]>
</alias>
...
@@ -73,6 +76,7 @@
...
@@ -73,6 +76,7 @@
<alias
name=
"volume-up"
target=
"output"
>
<![CDATA[<volume-up xmlns="urn:xmpp:rayo:output:1"/>]]>
</alias>
<alias
name=
"volume-up"
target=
"output"
>
<![CDATA[<volume-up xmlns="urn:xmpp:rayo:output:1"/>]]>
</alias>
<alias
name=
"volume-down"
target=
"output"
>
<![CDATA[<volume-down xmlns="urn:xmpp:rayo:output:1"/>]]>
</alias>
<alias
name=
"volume-down"
target=
"output"
>
<![CDATA[<volume-down xmlns="urn:xmpp:rayo:output:1"/>]]>
</alias>
<alias
name=
"receivefax"
target=
"call"
>
<![CDATA[<receivefax xmlns="urn:xmpp:rayo:fax:1"/>]]>
</alias>
<alias
name=
"receivefax"
target=
"call"
>
<![CDATA[<receivefax xmlns="urn:xmpp:rayo:fax:1"/>]]>
</alias>
<alias
name=
"sendfax"
target=
"call"
args=
"1"
>
<![CDATA[<sendfax xmlns="urn:xmpp:rayo:fax:1"><document xmlns="urn:xmpp:rayo:fax:1" url="$1"/></sendfax>]]>
</alias>
<alias
name=
"record"
target=
"call"
>
<![CDATA[<record xmlns="urn:xmpp:rayo:record:1"/>]]>
</alias>
<alias
name=
"record"
target=
"call"
>
<![CDATA[<record xmlns="urn:xmpp:rayo:record:1"/>]]>
</alias>
<alias
name=
"record_pause"
target=
"record"
>
<![CDATA[<pause xmlns="urn:xmpp:rayo:record:1"/>]]>
</alias>
<alias
name=
"record_pause"
target=
"record"
>
<![CDATA[<pause xmlns="urn:xmpp:rayo:record:1"/>]]>
</alias>
<alias
name=
"record_resume"
target=
"record"
>
<![CDATA[<resume xmlns="urn:xmpp:rayo:record:1"/>]]>
</alias>
<alias
name=
"record_resume"
target=
"record"
>
<![CDATA[<resume xmlns="urn:xmpp:rayo:record:1"/>]]>
</alias>
...
...
src/mod/event_handlers/mod_rayo/mod_rayo.c
浏览文件 @
cf0a3bbf
...
@@ -3405,19 +3405,41 @@ static void on_xmpp_stream_destroy(struct xmpp_stream *stream)
...
@@ -3405,19 +3405,41 @@ static void on_xmpp_stream_destroy(struct xmpp_stream *stream)
}
}
}
}
/**
* A command alias
*/
struct
rayo_cmd_alias
{
/** number of additional arguments for alias */
int
args
;
/** the alias template */
const
char
*
cmd
;
};
/**
/**
* Add an alias to an API command
* Add an alias to an API command
* @param alias_name
* @param alias_name
* @param alias_target
* @param alias_target
* @param alias_cmd
* @param alias_cmd
* @param alias_args
*/
*/
static
void
rayo_add_cmd_alias
(
const
char
*
alias_name
,
const
char
*
alias_target
,
const
char
*
alias_cmd
)
static
void
rayo_add_cmd_alias
(
const
char
*
alias_name
,
const
char
*
alias_target
,
const
char
*
alias_cmd
,
const
char
*
alias_args
)
{
{
struct
rayo_cmd_alias
*
alias
=
switch_core_alloc
(
globals
.
pool
,
sizeof
(
*
alias
));
alias
->
args
=
0
;
if
(
switch_is_number
(
alias_args
))
{
alias
->
args
=
atoi
(
alias_args
);
if
(
alias
->
args
<
0
)
{
alias
->
args
=
0
;
}
}
alias
->
cmd
=
alias_cmd
;
switch_core_hash_insert
(
globals
.
cmd_aliases
,
alias_name
,
alias
);
/* set up autocomplete of alias */
if
(
zstr
(
alias_target
))
{
if
(
zstr
(
alias_target
))
{
alias_target
=
"all"
;
alias_target
=
"all"
;
}
}
switch_console_set_complete
(
switch_core_sprintf
(
globals
.
pool
,
"add rayo %s ::rayo::list_%s"
,
alias_name
,
alias_target
));
switch_console_set_complete
(
switch_core_sprintf
(
globals
.
pool
,
"add rayo %s ::rayo::list_%s"
,
alias_name
,
alias_target
));
switch_core_hash_insert
(
globals
.
cmd_aliases
,
alias_name
,
alias_cmd
);
}
}
/**
/**
...
@@ -3614,8 +3636,9 @@ static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_
...
@@ -3614,8 +3636,9 @@ static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_
for
(
alias
=
switch_xml_child
(
aliases
,
"alias"
);
alias
;
alias
=
alias
->
next
)
{
for
(
alias
=
switch_xml_child
(
aliases
,
"alias"
);
alias
;
alias
=
alias
->
next
)
{
const
char
*
alias_name
=
switch_xml_attr_soft
(
alias
,
"name"
);
const
char
*
alias_name
=
switch_xml_attr_soft
(
alias
,
"name"
);
const
char
*
alias_target
=
switch_xml_attr_soft
(
alias
,
"target"
);
const
char
*
alias_target
=
switch_xml_attr_soft
(
alias
,
"target"
);
const
char
*
alias_args
=
switch_xml_attr_soft
(
alias
,
"args"
);
if
(
!
zstr
(
alias_name
)
&&
!
zstr
(
alias
->
txt
))
{
if
(
!
zstr
(
alias_name
)
&&
!
zstr
(
alias
->
txt
))
{
rayo_add_cmd_alias
(
alias_name
,
switch_core_strdup
(
pool
,
alias_target
),
switch_core_strdup
(
pool
,
alias
->
txt
));
rayo_add_cmd_alias
(
alias_name
,
switch_core_strdup
(
pool
,
alias_target
),
switch_core_strdup
(
pool
,
alias
->
txt
)
,
switch_core_strdup
(
pool
,
alias_args
)
);
}
}
}
}
}
}
...
@@ -3779,15 +3802,46 @@ static int command_api(char *cmd, switch_stream_handle_t *stream)
...
@@ -3779,15 +3802,46 @@ static int command_api(char *cmd, switch_stream_handle_t *stream)
/**
/**
* Send command to rayo actor
* Send command to rayo actor
*/
*/
static
int
alias_api
(
const
char
*
cmd
,
char
*
jid
,
switch_stream_handle_t
*
stream
)
static
int
alias_api
(
struct
rayo_cmd_alias
*
alias
,
char
*
args
,
switch_stream_handle_t
*
stream
)
{
{
if
(
zstr
(
cmd
)
||
zstr
(
jid
))
{
char
*
argv
[
10
]
=
{
0
};
return
0
;
int
argc
,
i
;
char
*
cmd
;
char
*
jid
;
if
(
zstr
(
alias
->
cmd
))
{
stream
->
write_function
(
stream
,
"-ERR missing alias template. Check configuration.
\n
"
);
}
if
(
zstr
(
args
))
{
stream
->
write_function
(
stream
,
"-ERR no args
\n
"
);
return
1
;
}
/* check args */
argc
=
switch_separate_string
(
args
,
' '
,
argv
,
sizeof
(
argv
)
/
sizeof
(
argv
[
0
]));
if
(
argc
!=
alias
->
args
+
1
)
{
stream
->
write_function
(
stream
,
"-ERR wrong number of args (%i/%i)
\n
"
,
argc
,
alias
->
args
+
1
);
return
1
;
}
jid
=
argv
[
0
];
/* build command from args */
cmd
=
strdup
(
alias
->
cmd
);
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
char
*
cmd_new
;
char
to_replace
[
4
]
=
{
0
};
sprintf
(
to_replace
,
"$%i"
,
i
);
cmd_new
=
switch_string_replace
(
cmd
,
to_replace
,
argv
[
i
]);
free
(
cmd
);
cmd
=
cmd_new
;
}
}
/* send command */
/* send command */
send_console_command
(
globals
.
console
,
jid
,
cmd
);
send_console_command
(
globals
.
console
,
jid
,
cmd
);
stream
->
write_function
(
stream
,
"+OK
\n
"
);
stream
->
write_function
(
stream
,
"+OK
\n
"
);
free
(
cmd
);
return
1
;
return
1
;
}
}
...
@@ -3881,7 +3935,7 @@ static int presence_api(char *cmd, switch_stream_handle_t *stream)
...
@@ -3881,7 +3935,7 @@ static int presence_api(char *cmd, switch_stream_handle_t *stream)
#define RAYO_API_SYNTAX "status | (<alias> <jid>) | (cmd <jid> <command>) | (msg <jid> <message text>) | (presence <jid> <online|offline>)"
#define RAYO_API_SYNTAX "status | (<alias> <jid>) | (cmd <jid> <command>) | (msg <jid> <message text>) | (presence <jid> <online|offline>)"
SWITCH_STANDARD_API
(
rayo_api
)
SWITCH_STANDARD_API
(
rayo_api
)
{
{
const
char
*
alias
;
struct
rayo_cmd_alias
*
alias
;
char
*
cmd_dup
=
strdup
(
cmd
);
char
*
cmd_dup
=
strdup
(
cmd
);
char
*
argv
[
2
]
=
{
0
};
char
*
argv
[
2
]
=
{
0
};
int
success
=
0
;
int
success
=
0
;
...
@@ -3891,7 +3945,7 @@ SWITCH_STANDARD_API(rayo_api)
...
@@ -3891,7 +3945,7 @@ SWITCH_STANDARD_API(rayo_api)
/* check if a command alias */
/* check if a command alias */
alias
=
switch_core_hash_find
(
globals
.
cmd_aliases
,
argv
[
0
]);
alias
=
switch_core_hash_find
(
globals
.
cmd_aliases
,
argv
[
0
]);
if
(
!
zstr
(
alias
)
)
{
if
(
alias
)
{
success
=
alias_api
(
alias
,
argv
[
1
],
stream
);
success
=
alias_api
(
alias
,
argv
[
1
],
stream
);
}
else
if
(
!
strcmp
(
"cmd"
,
argv
[
0
]))
{
}
else
if
(
!
strcmp
(
"cmd"
,
argv
[
0
]))
{
success
=
command_api
(
argv
[
1
],
stream
);
success
=
command_api
(
argv
[
1
],
stream
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论