%typemap(csclassmodifiers) switch_xml_flag_t "[System.Flags] public enum"\r
%typemap(csclassmodifiers) switch_xml_section_enum_t "[System.Flags] public enum"\r
\r
-\r
// Some things we dont want exposed to managed users directly, since \r
// we're gonna handle them with our own internalcall methods\r
-%ignore dtmfDelegateHandle;\r
-%ignore hangupDelegateHandle;\r
+%ignore dtmfDelegate;\r
+%ignore hangupDelegate;\r
%ignore setHangupHook;\r
%ignore beginAllowThreads;\r
%ignore endAllowThreads;\r
\r
%include switch.h\r
%include switch_types.h\r
+//%include switch_apr.h\r
\r
%include switch_core_db.h\r
%include switch_regex.h\r
#include "freeswitch_managed.h"\r
\r
#ifdef _MANAGED\r
+#define ATTACH_THREADS\r
+#else\r
+#define ATTACH_THREADS mono_thread_attach(globals.domain);\r
+#endif\r
\r
ManagedSession::ManagedSession():CoreSession() \r
{\r
\r
} \r
\r
-ManagedSession::~ManagedSession() \r
-{\r
- // Do auto-hangup ourselves because CoreSession can't call check_hangup_hook \r
- // after ManagedSession destruction (cause at point it's pure virtual)\r
- if (session) {\r
- channel = switch_core_session_get_channel(session);\r
- if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {\r
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);\r
- setAutoHangup(0);\r
- }\r
- // Don't let any callbacks use this CoreSession anymore\r
- switch_channel_set_private(channel, "CoreSession", NULL);\r
- }\r
-}\r
-\r
bool ManagedSession::begin_allow_threads() \r
{\r
return true;\r
return true;\r
}\r
\r
-void ManagedSession::check_hangup_hook() \r
-{\r
- if (!hangupDelegate) {\r
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangupDelegateHandle didn't get an object.");\r
- return;\r
- }\r
- hangupDelegate();\r
-}\r
-\r
-switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype) \r
-{\r
- if (!dtmfDelegate) {\r
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmfDelegateHandle didn't get an object.");\r
- return SWITCH_STATUS_FALSE;;\r
- }\r
- char *result = dtmfDelegate(input, itype);\r
-\r
- switch_status_t status = process_callback_result(result);\r
- Marshal::FreeCoTaskMem(IntPtr(result)); // I think this is right\r
- return status;\r
-}\r
-\r
-#else\r
-\r
-ManagedSession::ManagedSession():CoreSession() \r
-{\r
-\r
-} \r
-\r
-ManagedSession::ManagedSession(char *uuid):CoreSession(uuid) \r
-{\r
-\r
-} \r
-\r
-ManagedSession::ManagedSession(switch_core_session_t *session):CoreSession(session) \r
-{\r
-\r
-} \r
\r
ManagedSession::~ManagedSession() \r
{\r
- mono_thread_attach(globals.domain);\r
-\r
+ ATTACH_THREADS\r
// Do auto-hangup ourselves because CoreSession can't call check_hangup_hook \r
// after ManagedSession destruction (cause at point it's pure virtual)\r
if (session) {\r
}\r
}\r
\r
-bool ManagedSession::begin_allow_threads() \r
-{\r
- return true;\r
-}\r
-\r
-bool ManagedSession::end_allow_threads() \r
-{\r
- return true;\r
-}\r
-\r
void ManagedSession::check_hangup_hook() \r
{\r
- mono_thread_attach(globals.domain);\r
+ ATTACH_THREADS\r
if (!hangupDelegate) {\r
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hangupDelegate is null.");\r
return;\r
}\r
hangupDelegate();\r
\r
switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype) \r
{\r
- mono_thread_attach(globals.domain);\r
+ ATTACH_THREADS\r
if (!dtmfDelegate) {\r
- return SWITCH_STATUS_SUCCESS;\r
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "dtmfDelegate is null.");\r
+ return SWITCH_STATUS_FALSE;;\r
}\r
- char *resPtr = dtmfDelegate(input, itype);\r
- switch_status_t status = process_callback_result(resPtr);\r
- g_free(resPtr);\r
+ char *result = dtmfDelegate(input, itype);\r
+ switch_status_t status = process_callback_result(result);\r
+\r
+#if WIN32\r
+ CoTaskMemFree(result); \r
+#else\r
+ g_free(result)\r
+#endif\r
return status;\r
}\r
\r
-#endif\r