Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
a5f07a80
提交
a5f07a80
authored
6月 01, 2010
作者:
Jeff Lenk
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MODLANG-165 Added wrapper for switch_event_bind for .net
上级
4fa8be62
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
120 行增加
和
0 行删除
+120
-0
EventBinding.cs
src/mod/languages/mod_managed/managed/EventBinding.cs
+119
-0
FreeSWITCH.Managed.csproj
...d/languages/mod_managed/managed/FreeSWITCH.Managed.csproj
+1
-0
没有找到文件。
src/mod/languages/mod_managed/managed/EventBinding.cs
0 → 100644
浏览文件 @
a5f07a80
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - mod_managed
* Copyright (C) 2008, Michael Giagnocavo <mgg@giagnocavo.net>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - mod_managed
*
* The Initial Developer of the Original Code is
* Michael Giagnocavo <mgg@giagnocavo.net>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Michael Giagnocavo <mgg@giagnocavo.net>
*
* EventBinding.cs - Helpers for switch_event_bind function
*
*/
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Runtime.InteropServices
;
using
System.Reflection
;
using
FreeSWITCH.Native
;
namespace
FreeSWITCH
{
public
class
EventBinding
:
IDisposable
{
public
class
EventBindingArgs
:
EventArgs
{
public
switch_event
EventObj
{
get
;
set
;
}
}
//typedef void (*switch_event_callback_t) (switch_event_t *);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
delegate
void
switch_event_callback_delegate
(
IntPtr
event_data
);
readonly
switch_event_callback_delegate
del
;
// Prevent GC
readonly
SWIGTYPE_p_f_p_switch_event__void
function
;
private
EventBinding
(
SWIGTYPE_p_f_p_switch_event__void
function
,
switch_event_callback_delegate
origDelegate
)
{
this
.
function
=
function
;
this
.
del
=
origDelegate
;
}
bool
disposed
;
public
void
Dispose
()
{
dispose
();
GC
.
SuppressFinalize
(
this
);
}
void
dispose
()
{
if
(
disposed
)
return
;
// HACK: FS crashes if we unbind after shutdown is pretty complete. This is still a race condition.
if
(
freeswitch
.
switch_core_ready
()
==
switch_bool_t
.
SWITCH_FALSE
)
return
;
freeswitch
.
switch_event_unbind_callback
(
this
.
function
);
disposed
=
true
;
}
~
EventBinding
()
{
dispose
();
}
public
static
switch_event
SwitchEventDupe
(
switch_event
evt
)
{
IntPtr
clone_ptr_ptr
=
Marshal
.
AllocCoTaskMem
(
IntPtr
.
Size
);
freeswitch
.
switch_event_dup
(
new
SWIGTYPE_p_p_switch_event
(
clone_ptr_ptr
,
false
),
evt
);
IntPtr
event_ptr
=
(
IntPtr
)
Marshal
.
PtrToStructure
(
clone_ptr_ptr
,
typeof
(
IntPtr
));
switch_event
dupe_evt
=
new
switch_event
(
event_ptr
,
false
);
Marshal
.
FreeCoTaskMem
(
clone_ptr_ptr
);
return
dupe_evt
;
}
public
static
IDisposable
Bind
(
string
id
,
switch_event_types_t
event_types
,
string
subclass_name
,
Action
<
EventBindingArgs
>
f
,
bool
dupe
)
{
switch_event_callback_delegate
boundFunc
;
if
(
dupe
)
{
boundFunc
=
(
eventObj
)
=>
{
var
args
=
new
EventBindingArgs
{
EventObj
=
SwitchEventDupe
(
new
switch_event
(
eventObj
,
false
))
};
f
(
args
);
};
}
else
{
boundFunc
=
(
eventObj
)
=>
{
var
args
=
new
EventBindingArgs
{
EventObj
=
new
switch_event
(
eventObj
,
false
)
};
f
(
args
);
};
}
var
fp
=
Marshal
.
GetFunctionPointerForDelegate
(
boundFunc
);
var
swigFp
=
new
SWIGTYPE_p_f_p_switch_event__void
(
fp
,
false
);
var
res
=
freeswitch
.
switch_event_bind
(
id
,
event_types
,
subclass_name
,
swigFp
,
null
);
if
(
res
!=
switch_status_t
.
SWITCH_STATUS_SUCCESS
)
{
throw
new
InvalidOperationException
(
"Call to switch_event_bind failed, result: "
+
res
+
"."
);
}
return
new
EventBinding
(
swigFp
,
boundFunc
);
}
}
}
\ No newline at end of file
src/mod/languages/mod_managed/managed/FreeSWITCH.Managed.csproj
浏览文件 @
a5f07a80
...
...
@@ -49,6 +49,7 @@
<ItemGroup>
<Compile
Include=
"AssemblyInfo.cs"
/>
<Compile
Include=
"ChannelVariables.cs"
/>
<Compile
Include=
"EventBinding.cs"
/>
<Compile
Include=
"ManagedSession.cs"
/>
<Compile
Include=
"Loader.cs"
/>
<Compile
Include=
"Extensions.cs"
/>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论