Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
14bf6c16
提交
14bf6c16
authored
11月 06, 2014
作者:
Artur Kraev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed code formatting.
Return ListDelegate
上级
fbe81ff8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
32 行删除
+19
-32
Loader.cs
src/mod/languages/mod_managed/managed/Loader.cs
+16
-30
mod_managed.cpp
src/mod/languages/mod_managed/mod_managed.cpp
+3
-2
没有找到文件。
src/mod/languages/mod_managed/managed/Loader.cs
浏览文件 @
14bf6c16
...
@@ -46,15 +46,16 @@ namespace FreeSWITCH {
...
@@ -46,15 +46,16 @@ namespace FreeSWITCH {
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ExecuteDelegate
(
string
cmd
,
IntPtr
streamH
,
IntPtr
eventH
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ExecuteDelegate
(
string
cmd
,
IntPtr
streamH
,
IntPtr
eventH
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ExecuteBackgroundDelegate
(
string
cmd
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ExecuteBackgroundDelegate
(
string
cmd
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
RunDelegate
(
string
cmd
,
IntPtr
session
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
RunDelegate
(
string
cmd
,
IntPtr
session
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ReloadDelegate
(
string
cmd
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ReloadDelegate
(
string
cmd
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
bool
ListDelegate
(
string
cmd
,
IntPtr
streamH
,
IntPtr
eventH
);
static
readonly
ExecuteDelegate
_execute
=
Execute
;
static
readonly
ExecuteDelegate
_execute
=
Execute
;
static
readonly
ExecuteBackgroundDelegate
_executeBackground
=
ExecuteBackground
;
static
readonly
ExecuteBackgroundDelegate
_executeBackground
=
ExecuteBackground
;
static
readonly
RunDelegate
_run
=
Run
;
static
readonly
RunDelegate
_run
=
Run
;
static
readonly
ReloadDelegate
_reload
=
Reload
;
static
readonly
ReloadDelegate
_reload
=
Reload
;
static
readonly
Execute
Delegate
_list
=
List
;
static
readonly
List
Delegate
_list
=
List
;
[
DllImport
(
"mod_managed"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"mod_managed"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
void
InitManagedDelegates
(
RunDelegate
run
,
ExecuteDelegate
execute
,
ExecuteBackgroundDelegate
executeBackground
,
ReloadDelegate
reload
,
Execute
Delegate
list
);
static
extern
void
InitManagedDelegates
(
RunDelegate
run
,
ExecuteDelegate
execute
,
ExecuteBackgroundDelegate
executeBackground
,
ReloadDelegate
reload
,
List
Delegate
list
);
static
readonly
object
loaderLock
=
new
object
();
static
readonly
object
loaderLock
=
new
object
();
...
@@ -64,14 +65,10 @@ namespace FreeSWITCH {
...
@@ -64,14 +65,10 @@ namespace FreeSWITCH {
public
static
bool
Load
()
{
public
static
bool
Load
()
{
managedDir
=
Path
.
Combine
(
Native
.
freeswitch
.
SWITCH_GLOBAL_dirs
.
mod_dir
,
"managed"
);
managedDir
=
Path
.
Combine
(
Native
.
freeswitch
.
SWITCH_GLOBAL_dirs
.
mod_dir
,
"managed"
);
shadowDir
=
Path
.
Combine
(
managedDir
,
"shadow"
);
shadowDir
=
Path
.
Combine
(
managedDir
,
"shadow"
);
if
(
Directory
.
Exists
(
shadowDir
))
if
(
Directory
.
Exists
(
shadowDir
))
{
{
try
{
try
{
Directory
.
Delete
(
shadowDir
,
true
);
Directory
.
Delete
(
shadowDir
,
true
);
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
Log
.
WriteLine
(
LogLevel
.
Warning
,
"Cannot delete shadow directory: {0}"
,
ex
);
Log
.
WriteLine
(
LogLevel
.
Warning
,
"Cannot delete shadow directory: {0}"
,
ex
);
}
}
...
@@ -79,8 +76,7 @@ namespace FreeSWITCH {
...
@@ -79,8 +76,7 @@ namespace FreeSWITCH {
}
}
Log
.
WriteLine
(
LogLevel
.
Debug
,
"FreeSWITCH.Managed loader is starting with directory '{0}'."
,
managedDir
);
Log
.
WriteLine
(
LogLevel
.
Debug
,
"FreeSWITCH.Managed loader is starting with directory '{0}'."
,
managedDir
);
if
(!
Directory
.
Exists
(
managedDir
))
if
(!
Directory
.
Exists
(
managedDir
))
{
{
Log
.
WriteLine
(
LogLevel
.
Error
,
"Managed directory not found: {0}"
,
managedDir
);
Log
.
WriteLine
(
LogLevel
.
Error
,
"Managed directory not found: {0}"
,
managedDir
);
return
false
;
return
false
;
}
}
...
@@ -241,8 +237,7 @@ namespace FreeSWITCH {
...
@@ -241,8 +237,7 @@ namespace FreeSWITCH {
.
ToList
();
.
ToList
();
// adding "managed" (modules) directory
// adding "managed" (modules) directory
if
(!
binPaths
.
Contains
(
"managed"
,
StringComparer
.
OrdinalIgnoreCase
))
if
(!
binPaths
.
Contains
(
"managed"
,
StringComparer
.
OrdinalIgnoreCase
))
{
{
binPaths
.
Add
(
"managed"
);
binPaths
.
Add
(
"managed"
);
}
}
...
@@ -250,11 +245,9 @@ namespace FreeSWITCH {
...
@@ -250,11 +245,9 @@ namespace FreeSWITCH {
var
moduleRefsDir
=
Path
.
GetFileName
(
fileName
);
var
moduleRefsDir
=
Path
.
GetFileName
(
fileName
);
moduleRefsDir
=
Path
.
GetFileNameWithoutExtension
(
moduleRefsDir
);
moduleRefsDir
=
Path
.
GetFileNameWithoutExtension
(
moduleRefsDir
);
if
(
moduleRefsDir
!=
null
&&
moduleRefsDir
.
Trim
()
!=
""
)
if
(
moduleRefsDir
!=
null
&&
moduleRefsDir
.
Trim
()
!=
""
)
{
{
moduleRefsDir
=
Path
.
Combine
(
"managed"
,
moduleRefsDir
);
moduleRefsDir
=
Path
.
Combine
(
"managed"
,
moduleRefsDir
);
if
(!
binPaths
.
Contains
(
moduleRefsDir
,
StringComparer
.
OrdinalIgnoreCase
))
if
(!
binPaths
.
Contains
(
moduleRefsDir
,
StringComparer
.
OrdinalIgnoreCase
))
{
{
binPaths
.
Add
(
moduleRefsDir
);
binPaths
.
Add
(
moduleRefsDir
);
}
}
}
}
...
@@ -446,12 +439,9 @@ namespace FreeSWITCH {
...
@@ -446,12 +439,9 @@ namespace FreeSWITCH {
public
static
bool
List
(
string
command
,
IntPtr
streamHandle
,
IntPtr
eventHandle
)
public
static
bool
List
(
string
command
,
IntPtr
streamHandle
,
IntPtr
eventHandle
)
{
{
try
try
{
{
if
(
streamHandle
!=
IntPtr
.
Zero
)
{
if
(
streamHandle
!=
IntPtr
.
Zero
)
using
(
var
stream
=
new
Native
.
Stream
(
new
Native
.
switch_stream_handle
(
streamHandle
,
false
)))
{
{
using
(
var
stream
=
new
Native
.
Stream
(
new
Native
.
switch_stream_handle
(
streamHandle
,
false
)))
{
stream
.
Write
(
"Available APIs:\n"
);
stream
.
Write
(
"Available APIs:\n"
);
getApiExecs
().
Values
.
ForEach
(
x
=>
stream
.
Write
(
string
.
Format
(
"{0}: {1}\n"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
()))));
getApiExecs
().
Values
.
ForEach
(
x
=>
stream
.
Write
(
string
.
Format
(
"{0}: {1}\n"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
()))));
...
@@ -459,18 +449,14 @@ namespace FreeSWITCH {
...
@@ -459,18 +449,14 @@ namespace FreeSWITCH {
stream
.
Write
(
"Available Apps:\n"
);
stream
.
Write
(
"Available Apps:\n"
);
getAppExecs
().
Values
.
ForEach
(
x
=>
stream
.
Write
(
string
.
Format
(
"{0}: {1}\n"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
()))));
getAppExecs
().
Values
.
ForEach
(
x
=>
stream
.
Write
(
string
.
Format
(
"{0}: {1}\n"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
()))));
}
}
}
}
else
{
else
{
Log
.
WriteLine
(
LogLevel
.
Info
,
"Available APIs:"
);
Log
.
WriteLine
(
LogLevel
.
Info
,
"Available APIs:"
);
getApiExecs
().
Values
.
ForEach
(
x
=>
Log
.
WriteLine
(
LogLevel
.
Info
,
"{0}: {1}"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
())));
getApiExecs
().
Values
.
ForEach
(
x
=>
Log
.
WriteLine
(
LogLevel
.
Info
,
"{0}: {1}"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
())));
Log
.
WriteLine
(
LogLevel
.
Info
,
"Available Apps:"
);
Log
.
WriteLine
(
LogLevel
.
Info
,
"Available Apps:"
);
getAppExecs
().
Values
.
ForEach
(
x
=>
Log
.
WriteLine
(
LogLevel
.
Info
,
"{0}: {1}"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
())));
getAppExecs
().
Values
.
ForEach
(
x
=>
Log
.
WriteLine
(
LogLevel
.
Info
,
"{0}: {1}"
,
x
.
Name
,
String
.
Join
(
","
,
x
.
Aliases
.
ToArray
())));
}
}
return
true
;
return
true
;
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
Log
.
WriteLine
(
LogLevel
.
Error
,
"Exception listing managed modules: {0}"
,
ex
.
ToString
());
Log
.
WriteLine
(
LogLevel
.
Error
,
"Exception listing managed modules: {0}"
,
ex
.
ToString
());
return
false
;
return
false
;
}
}
...
...
src/mod/languages/mod_managed/mod_managed.cpp
浏览文件 @
14bf6c16
...
@@ -74,13 +74,14 @@ typedef int (*runFunction)(const char *data, void *sessionPtr);
...
@@ -74,13 +74,14 @@ typedef int (*runFunction)(const char *data, void *sessionPtr);
typedef
int
(
*
executeFunction
)(
const
char
*
cmd
,
void
*
stream
,
void
*
Event
);
typedef
int
(
*
executeFunction
)(
const
char
*
cmd
,
void
*
stream
,
void
*
Event
);
typedef
int
(
*
executeBackgroundFunction
)(
const
char
*
cmd
);
typedef
int
(
*
executeBackgroundFunction
)(
const
char
*
cmd
);
typedef
int
(
*
reloadFunction
)(
const
char
*
cmd
);
typedef
int
(
*
reloadFunction
)(
const
char
*
cmd
);
typedef
int
(
*
listFunction
)(
const
char
*
cmd
,
void
*
stream
,
void
*
Event
);
static
runFunction
runDelegate
;
static
runFunction
runDelegate
;
static
executeFunction
executeDelegate
;
static
executeFunction
executeDelegate
;
static
executeBackgroundFunction
executeBackgroundDelegate
;
static
executeBackgroundFunction
executeBackgroundDelegate
;
static
reloadFunction
reloadDelegate
;
static
reloadFunction
reloadDelegate
;
static
execute
Function
listDelegate
;
static
list
Function
listDelegate
;
SWITCH_MOD_DECLARE_NONSTD
(
void
)
InitManagedDelegates
(
runFunction
run
,
executeFunction
execute
,
executeBackgroundFunction
executeBackground
,
reloadFunction
reload
,
execute
Function
list
)
SWITCH_MOD_DECLARE_NONSTD
(
void
)
InitManagedDelegates
(
runFunction
run
,
executeFunction
execute
,
executeBackgroundFunction
executeBackground
,
reloadFunction
reload
,
list
Function
list
)
{
{
runDelegate
=
run
;
runDelegate
=
run
;
executeDelegate
=
execute
;
executeDelegate
=
execute
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论