mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
Unified Mono and CLR in freeswitch_managed
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9819 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -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,8 +65,20 @@ ManagedSession::ManagedSession(switch_core_session_t *session):CoreSession(sessi
|
||||
|
||||
}
|
||||
|
||||
bool ManagedSession::begin_allow_threads()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ManagedSession::end_allow_threads()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ManagedSession::~ManagedSession()
|
||||
{
|
||||
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) {
|
||||
@@ -76,20 +92,11 @@ ManagedSession::~ManagedSession()
|
||||
}
|
||||
}
|
||||
|
||||
bool ManagedSession::begin_allow_threads()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ManagedSession::end_allow_threads()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ManagedSession::check_hangup_hook()
|
||||
{
|
||||
ATTACH_THREADS
|
||||
if (!hangupDelegate) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangupDelegateHandle didn't get an object.");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hangupDelegate is null.");
|
||||
return;
|
||||
}
|
||||
hangupDelegate();
|
||||
@@ -97,80 +104,19 @@ void ManagedSession::check_hangup_hook()
|
||||
|
||||
switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
|
||||
{
|
||||
ATTACH_THREADS
|
||||
if (!dtmfDelegate) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmfDelegateHandle didn't get an object.");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "dtmfDelegate is null.");
|
||||
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;
|
||||
}
|
||||
|
||||
#if WIN32
|
||||
CoTaskMemFree(result);
|
||||
#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);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
bool ManagedSession::end_allow_threads()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ManagedSession::check_hangup_hook()
|
||||
{
|
||||
mono_thread_attach(globals.domain);
|
||||
if (!hangupDelegate) {
|
||||
return;
|
||||
}
|
||||
hangupDelegate();
|
||||
}
|
||||
|
||||
switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
|
||||
{
|
||||
mono_thread_attach(globals.domain);
|
||||
if (!dtmfDelegate) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
char *resPtr = dtmfDelegate(input, itype);
|
||||
switch_status_t status = process_callback_result(resPtr);
|
||||
g_free(resPtr);
|
||||
g_free(result)
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user