[Freeswitch-svn] [commit] r8789 - freeswitch/trunk/src/mod/languages/mod_mono
Freeswitch SVN
michaelgg at freeswitch.org
Sun Jun 8 20:09:42 EDT 2008
Author: michaelgg
Date: Sun Jun 8 20:09:42 2008
New Revision: 8789
Modified:
freeswitch/trunk/src/mod/languages/mod_mono/freeswitch_mono.cpp
Log:
Hack patch to avoid hanguphook calling check_hangup_hook purely virtually
Modified: freeswitch/trunk/src/mod/languages/mod_mono/freeswitch_mono.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_mono/freeswitch_mono.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_mono/freeswitch_mono.cpp Sun Jun 8 20:09:42 2008
@@ -38,71 +38,107 @@
#include <mono/metadata/threads.h>
#include <mono/metadata/metadata.h>
#include "freeswitch_mono.h"
-
MonoSession::MonoSession():CoreSession()
-{
-
}
MonoSession::MonoSession(char *uuid):CoreSession(uuid)
-{
-
}
MonoSession::MonoSession(switch_core_session_t *session):CoreSession(session)
-{
-
}
MonoSession::~MonoSession()
-{
-
mono_thread_attach(globals.domain);
-
if (dtmfDelegateHandle)
- mono_gchandle_free(dtmfDelegateHandle);
-
if (hangupDelegateHandle)
- mono_gchandle_free(hangupDelegateHandle);
-
}
-
-
bool MonoSession::begin_allow_threads()
-{
-
return true;
-
}
-
-
bool MonoSession::end_allow_threads()
-{
-
return true;
-
}
-
void MonoSession::check_hangup_hook()
-{
-
mono_thread_attach(globals.domain);
-
if (!hangupDelegateHandle) {
-
return;
-
}
-
MonoObject * hangupDelegate = mono_gchandle_get_target(hangupDelegateHandle);
-
if (!hangupDelegate) {
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangupDelegateHandle didn't get an object.");
-
return;
-
}
-
MonoObject * ex = NULL;
-
mono_runtime_delegate_invoke(hangupDelegate, NULL, &ex);
-
if (ex) {
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangupDelegate threw an exception.");
-
}
-
}
-
switch_status_t MonoSession::run_dtmf_callback(void *input, switch_input_type_t itype)
-{
-
mono_thread_attach(globals.domain);
-
if (!dtmfDelegateHandle) {
-
return SWITCH_STATUS_SUCCESS;
-
}
-
MonoObject * dtmfDelegate = mono_gchandle_get_target(dtmfDelegateHandle);
-
if (!dtmfDelegate) {
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmfDelegateHandle didn't get an object.");
-
return SWITCH_STATUS_SUCCESS;
-
}
-
void *args[2];
-
args[0] = &input;
-
args[1] = &itype;
-
MonoObject * ex = NULL;
-
MonoObject * res = mono_runtime_delegate_invoke(dtmfDelegate, args, &ex);
-
if (ex) {
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmfDelegate threw an exception.");
-
return SWITCH_STATUS_FALSE;
-
}
-
char *resPtr = mono_string_to_utf8((MonoString *) res);
-
switch_status_t status = process_callback_result(resPtr);
-
g_free(resPtr);
-
return status;
-
}
-
+
+MonoSession::MonoSession():CoreSession()
+{
+
+}
+
+MonoSession::MonoSession(char *uuid):CoreSession(uuid)
+{
+
+}
+
+MonoSession::MonoSession(switch_core_session_t *session):CoreSession(session)
+{
+
+}
+
+MonoSession::~MonoSession()
+{
+ mono_thread_attach(globals.domain);
+
+ if (dtmfDelegateHandle) {
+ mono_gchandle_free(dtmfDelegateHandle);
+ }
+
+ if (hangupDelegateHandle) {
+ mono_gchandle_free(hangupDelegateHandle);
+ }
+
+ // Do auto-hangup ourselves because CoreSession can't call check_hangup_hook
+ // after MonoSession 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);
+ }
+ }
+}
+
+
+
+bool MonoSession::begin_allow_threads()
+{
+ return true;
+}
+
+
+
+bool MonoSession::end_allow_threads()
+{
+ return true;
+}
+
+
+void MonoSession::check_hangup_hook()
+{
+ mono_thread_attach(globals.domain);
+ if (!hangupDelegateHandle) {
+ return;
+ }
+
+ MonoObject * hangupDelegate = mono_gchandle_get_target(hangupDelegateHandle);
+ if (!hangupDelegate) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangupDelegateHandle didn't get an object.");
+ return;
+ }
+
+ MonoObject * ex = NULL;
+ mono_runtime_delegate_invoke(hangupDelegate, NULL, &ex);
+ if (ex) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangupDelegate threw an exception.");
+ }
+}
+
+
+switch_status_t MonoSession::run_dtmf_callback(void *input, switch_input_type_t itype)
+{
+ mono_thread_attach(globals.domain);
+ if (!dtmfDelegateHandle) {
+ return SWITCH_STATUS_SUCCESS;
+ }
+ MonoObject * dtmfDelegate = mono_gchandle_get_target(dtmfDelegateHandle);
+ if (!dtmfDelegate) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmfDelegateHandle didn't get an object.");
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ void *args[2];
+ args[0] = &input;
+ args[1] = &itype;
+ MonoObject * ex = NULL;
+ MonoObject * res = mono_runtime_delegate_invoke(dtmfDelegate, args, &ex);
+ if (ex) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmfDelegate threw an exception.");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ char *resPtr = mono_string_to_utf8((MonoString *) res);
+ switch_status_t status = process_callback_result(resPtr);
+ g_free(resPtr);
+ return status;
+}
+
More information about the Freeswitch-svn
mailing list