Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
535e6ece
提交
535e6ece
authored
11月 03, 2011
作者:
Michael Giagnocavo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add simple managedlist function to print out loaded APIs/Apps
上级
6cd6a719
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
43 行增加
和
6 行删除
+43
-6
Loader.cs
src/mod/languages/mod_managed/managed/Loader.cs
+23
-4
mod_managed.cpp
src/mod/languages/mod_managed/mod_managed.cpp
+20
-2
没有找到文件。
src/mod/languages/mod_managed/managed/Loader.cs
浏览文件 @
535e6ece
...
...
@@ -47,13 +47,15 @@ namespace FreeSWITCH {
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ExecuteBackgroundDelegate
(
string
cmd
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
RunDelegate
(
string
cmd
,
IntPtr
session
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ReloadDelegate
(
string
cmd
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ListDelegate
(
string
cmd
);
static
readonly
ExecuteDelegate
_execute
=
Execute
;
static
readonly
ExecuteBackgroundDelegate
_executeBackground
=
ExecuteBackground
;
static
readonly
RunDelegate
_run
=
Run
;
static
readonly
ReloadDelegate
_reload
=
Reload
;
//SWITCH_MOD_DECLARE_NONSTD(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, reloadFunction reload)
static
readonly
ListDelegate
_list
=
List
;
[
DllImport
(
"mod_managed"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
void
InitManagedDelegates
(
RunDelegate
run
,
ExecuteDelegate
execute
,
ExecuteBackgroundDelegate
executeBackground
,
ReloadDelegate
reload
);
static
extern
void
InitManagedDelegates
(
RunDelegate
run
,
ExecuteDelegate
execute
,
ExecuteBackgroundDelegate
executeBackground
,
ReloadDelegate
reload
,
ListDelegate
list
);
static
readonly
object
loaderLock
=
new
object
();
...
...
@@ -83,7 +85,7 @@ namespace FreeSWITCH {
return
File
.
Exists
(
path
)
?
Assembly
.
LoadFile
(
path
)
:
null
;
};
InitManagedDelegates
(
_run
,
_execute
,
_executeBackground
,
_reload
);
InitManagedDelegates
(
_run
,
_execute
,
_executeBackground
,
_reload
,
_list
);
configureWatcher
();
...
...
@@ -405,7 +407,24 @@ namespace FreeSWITCH {
return
false
;
}
}
public
static
bool
List
(
string
command
)
{
try
{
Log
.
WriteLine
(
LogLevel
.
Info
,
"Available APIs:"
);
getApiExecs
().
Values
.
ForEach
(
x
=>
{
Log
.
WriteLine
(
LogLevel
.
Info
,
"{0}: {1}"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
()));
});
Log
.
WriteLine
(
LogLevel
.
Info
,
"Available Apps:"
);
getAppExecs
().
Values
.
ForEach
(
x
=>
{
Log
.
WriteLine
(
LogLevel
.
Info
,
"{0}: {1}"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
()));
});
return
true
;
}
catch
(
Exception
ex
)
{
Log
.
WriteLine
(
LogLevel
.
Error
,
"Exception listing managed modules: {0}"
,
ex
.
ToString
());
return
false
;
}
}
}
}
\ No newline at end of file
src/mod/languages/mod_managed/mod_managed.cpp
浏览文件 @
535e6ece
...
...
@@ -23,7 +23,7 @@
*
* Contributor(s):
*
* Michael Giagnocavo <mgg@
packetrino.com
>
* Michael Giagnocavo <mgg@
giagnocavo.net
>
* David Brazier <David.Brazier@360crm.co.uk>
* Jeff Lenk <jlenk@frontiernet.net>
*
...
...
@@ -55,6 +55,7 @@ SWITCH_STANDARD_API(managedrun_api_function); /* ExecuteBackground */
SWITCH_STANDARD_API
(
managed_api_function
);
/* Execute */
SWITCH_STANDARD_APP
(
managed_app_function
);
/* Run */
SWITCH_STANDARD_API
(
managedreload_api_function
);
/* Reload */
SWITCH_STANDARD_API
(
managedlist_api_function
);
/* List modules */
#define MOD_MANAGED_ASM_NAME "FreeSWITCH.Managed"
#define MOD_MANAGED_ASM_V1 1
...
...
@@ -72,19 +73,23 @@ typedef int (*runFunction)(const char *data, void *sessionPtr);
typedef
int
(
*
executeFunction
)(
const
char
*
cmd
,
void
*
stream
,
void
*
Event
);
typedef
int
(
*
executeBackgroundFunction
)(
const
char
*
cmd
);
typedef
int
(
*
reloadFunction
)(
const
char
*
cmd
);
typedef
int
(
*
listFunction
)(
const
char
*
cmd
);
static
runFunction
runDelegate
;
static
executeFunction
executeDelegate
;
static
executeBackgroundFunction
executeBackgroundDelegate
;
static
reloadFunction
reloadDelegate
;
static
listFunction
listDelegate
;
SWITCH_MOD_DECLARE_NONSTD
(
void
)
InitManagedDelegates
(
runFunction
run
,
executeFunction
execute
,
executeBackgroundFunction
executeBackground
,
reloadFunction
reload
)
SWITCH_MOD_DECLARE_NONSTD
(
void
)
InitManagedDelegates
(
runFunction
run
,
executeFunction
execute
,
executeBackgroundFunction
executeBackground
,
reloadFunction
reload
,
listFunction
list
)
{
runDelegate
=
run
;
executeDelegate
=
execute
;
executeBackgroundDelegate
=
executeBackground
;
reloadDelegate
=
reload
;
listDelegate
=
list
;
}
// Sets up delegates (and anything else needed) on the ManagedSession object
// Called from ManagedSession.Initialize Managed -> this is Unmanaged code so all pointers are marshalled and prevented from GC
// Exported method.
...
...
@@ -361,6 +366,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load)
SWITCH_ADD_API
(
api_interface
,
"managed"
,
"Run a module as an API function (Execute)"
,
managed_api_function
,
"<module> [<args>]"
);
SWITCH_ADD_APP
(
app_interface
,
"managed"
,
"Run CLI App"
,
"Run an App on a channel"
,
managed_app_function
,
"<modulename> [<args>]"
,
SAF_SUPPORT_NOMEDIA
);
SWITCH_ADD_API
(
api_interface
,
"managedreload"
,
"Force [re]load of a file"
,
managedreload_api_function
,
"<filename>"
);
SWITCH_ADD_API
(
api_interface
,
"managedlist"
,
"Log the list of available APIs and Apps"
,
managedlist_api_function
,
""
);
return
SWITCH_STATUS_NOUNLOAD
;
}
...
...
@@ -440,4 +446,16 @@ SWITCH_STANDARD_API(managedreload_api_function)
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_STANDARD_API
(
managedlist_api_function
)
{
#ifndef _MANAGED
mono_thread_attach
(
globals
.
domain
);
#endif
listDelegate
(
cmd
);
#ifndef _MANAGED
mono_thread_detach
(
mono_thread_current
());
#endif
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_END_EXTERN_C
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论