提交 b32e3e61 authored 作者: Michael Giagnocavo's avatar Michael Giagnocavo

Unified Mono and CLR in freeswitch_managed

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9819 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 20336f58
......@@ -39,11 +39,10 @@
%typemap(csclassmodifiers) switch_xml_flag_t "[System.Flags] public enum"
%typemap(csclassmodifiers) switch_xml_section_enum_t "[System.Flags] public enum"
// Some things we dont want exposed to managed users directly, since
// we're gonna handle them with our own internalcall methods
%ignore dtmfDelegateHandle;
%ignore hangupDelegateHandle;
%ignore dtmfDelegate;
%ignore hangupDelegate;
%ignore setHangupHook;
%ignore beginAllowThreads;
%ignore endAllowThreads;
......@@ -114,6 +113,7 @@
%include switch.h
%include switch_types.h
//%include switch_apr.h
%include switch_core_db.h
%include switch_regex.h
......
......@@ -45,6 +45,10 @@
#include "freeswitch_managed.h"
#ifdef _MANAGED
#define ATTACH_THREADS
#else
#define ATTACH_THREADS mono_thread_attach(globals.domain);
#endif
ManagedSession::ManagedSession():CoreSession()
{
......@@ -61,21 +65,6 @@ ManagedSession::ManagedSession(switch_core_session_t *session):CoreSession(sessi
}
ManagedSession::~ManagedSession()
{
// Do auto-hangup ourselves because CoreSession can't call check_hangup_hook
// after ManagedSession destruction (cause at point it's pure virtual)
if (session) {
channel = switch_core_session_get_channel(session);
if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
setAutoHangup(0);
}
// Don't let any callbacks use this CoreSession anymore
switch_channel_set_private(channel, "CoreSession", NULL);
}
}
bool ManagedSession::begin_allow_threads()
{
return true;
......@@ -86,49 +75,10 @@ bool ManagedSession::end_allow_threads()
return true;
}
void ManagedSession::check_hangup_hook()
{
if (!hangupDelegate) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangupDelegateHandle didn't get an object.");
return;
}
hangupDelegate();
}
switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
{
if (!dtmfDelegate) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmfDelegateHandle didn't get an object.");
return SWITCH_STATUS_FALSE;;
}
char *result = dtmfDelegate(input, itype);
switch_status_t status = process_callback_result(result);
Marshal::FreeCoTaskMem(IntPtr(result)); // I think this is right
return status;
}
#else
ManagedSession::ManagedSession():CoreSession()
{
}
ManagedSession::ManagedSession(char *uuid):CoreSession(uuid)
{
}
ManagedSession::ManagedSession(switch_core_session_t *session):CoreSession(session)
{
}
ManagedSession::~ManagedSession()
{
mono_thread_attach(globals.domain);
ATTACH_THREADS
// Do auto-hangup ourselves because CoreSession can't call check_hangup_hook
// after ManagedSession destruction (cause at point it's pure virtual)
if (session) {
......@@ -142,20 +92,11 @@ ManagedSession::~ManagedSession()
}
}
bool ManagedSession::begin_allow_threads()
{
return true;
}
bool ManagedSession::end_allow_threads()
{
return true;
}
void ManagedSession::check_hangup_hook()
{
mono_thread_attach(globals.domain);
ATTACH_THREADS
if (!hangupDelegate) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hangupDelegate is null.");
return;
}
hangupDelegate();
......@@ -163,14 +104,19 @@ void ManagedSession::check_hangup_hook()
switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
{
mono_thread_attach(globals.domain);
ATTACH_THREADS
if (!dtmfDelegate) {
return SWITCH_STATUS_SUCCESS;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "dtmfDelegate is null.");
return SWITCH_STATUS_FALSE;;
}
char *resPtr = dtmfDelegate(input, itype);
switch_status_t status = process_callback_result(resPtr);
g_free(resPtr);
char *result = dtmfDelegate(input, itype);
switch_status_t status = process_callback_result(result);
#if WIN32
CoTaskMemFree(result);
#else
g_free(result)
#endif
return status;
}
#endif
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论