提交 33cb9505 authored 作者: Artur Kraev's avatar Artur Kraev

mod_managed: Added pure CreateStateHandlerDelegate in ManagedSession for native api usage

上级 10ebebaa
......@@ -149,6 +149,23 @@ namespace FreeSWITCH.Native
};
return del;
}
/// <summary>Wraps a nice handler into a delegate suitable for reverse P/Invoke. For native api using</summary>
public static switch_state_handler_t_delegate CreateStateHandlerDelegate(Action<ManagedSession> handler)
{
// We create a ManagedSession on top of the session so callbacks can use it "nicely"
// Then we sort of dispose it.
switch_state_handler_t_delegate del = ptr =>
{
using (var sess = new ManagedSession(new SWIGTYPE_p_switch_core_session(ptr, false)))
{
handler(sess);
return switch_status_t.SWITCH_STATUS_SUCCESS;
}
};
return del;
}
public static SWIGTYPE_p_f_p_switch_core_session__switch_status_t WrapStateHandlerDelegate(switch_state_handler_t_delegate del) {
return new SWIGTYPE_p_f_p_switch_core_session__switch_status_t(Marshal.GetFunctionPointerForDelegate(del), false);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论