mod_managed: managedlist command must return value to api stream instead of log
This commit is contained in:
parent
12b6940644
commit
7c0cf506d8
|
@ -26,6 +26,7 @@
|
||||||
* Michael Giagnocavo <mgg@giagnocavo.net>
|
* Michael Giagnocavo <mgg@giagnocavo.net>
|
||||||
* David Brazier <David.Brazier@360crm.co.uk>
|
* David Brazier <David.Brazier@360crm.co.uk>
|
||||||
* Jeff Lenk <jeff@jefflenk.com>
|
* Jeff Lenk <jeff@jefflenk.com>
|
||||||
|
* Artur Kraev <ravenox@gmail.com>
|
||||||
*
|
*
|
||||||
* Loader.cs -- mod_managed loader
|
* Loader.cs -- mod_managed loader
|
||||||
*
|
*
|
||||||
|
@ -33,7 +34,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -46,16 +46,15 @@ namespace FreeSWITCH {
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ExecuteDelegate(string cmd, IntPtr streamH, IntPtr eventH);
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ExecuteDelegate(string cmd, IntPtr streamH, IntPtr eventH);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ExecuteBackgroundDelegate(string cmd);
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ExecuteBackgroundDelegate(string cmd);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool RunDelegate(string cmd, IntPtr session);
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool RunDelegate(string cmd, IntPtr session);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ReloadDelegate(string cmd);
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ReloadDelegate(string cmd);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ListDelegate(string cmd);
|
|
||||||
static readonly ExecuteDelegate _execute = Execute;
|
static readonly ExecuteDelegate _execute = Execute;
|
||||||
static readonly ExecuteBackgroundDelegate _executeBackground = ExecuteBackground;
|
static readonly ExecuteBackgroundDelegate _executeBackground = ExecuteBackground;
|
||||||
static readonly RunDelegate _run = Run;
|
static readonly RunDelegate _run = Run;
|
||||||
static readonly ReloadDelegate _reload = Reload;
|
static readonly ReloadDelegate _reload = Reload;
|
||||||
static readonly ListDelegate _list = List;
|
static readonly ExecuteDelegate _list = List;
|
||||||
|
|
||||||
[DllImport("mod_managed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("mod_managed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, ReloadDelegate reload, ListDelegate list);
|
static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, ReloadDelegate reload, ExecuteDelegate list);
|
||||||
|
|
||||||
static readonly object loaderLock = new object();
|
static readonly object loaderLock = new object();
|
||||||
|
|
||||||
|
@ -408,18 +407,33 @@ namespace FreeSWITCH {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool List(string command) {
|
public static bool List(string command, IntPtr streamHandle, IntPtr eventHandle)
|
||||||
try {
|
{
|
||||||
Log.WriteLine(LogLevel.Info, "Available APIs:");
|
try
|
||||||
getApiExecs().Values.ForEach(x => {
|
{
|
||||||
Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray()));
|
if (streamHandle != IntPtr.Zero)
|
||||||
});
|
{
|
||||||
Log.WriteLine(LogLevel.Info, "Available Apps:");
|
using (var stream = new Native.Stream(new Native.switch_stream_handle(streamHandle, false)))
|
||||||
getAppExecs().Values.ForEach(x => {
|
{
|
||||||
Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray()));
|
stream.Write("Available APIs:\n");
|
||||||
});
|
|
||||||
|
getApiExecs().Values.ForEach(x => stream.Write(string.Format("{0}: {1}\n", x.Name, String.Join(",", x.Aliases.ToArray()))));
|
||||||
|
|
||||||
|
stream.Write("Available Apps:\n");
|
||||||
|
getAppExecs().Values.ForEach(x => stream.Write(string.Format("{0}: {1}\n", x.Name, String.Join(",", x.Aliases.ToArray()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.WriteLine(LogLevel.Info, "Available APIs:");
|
||||||
|
getApiExecs().Values.ForEach(x => Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray())));
|
||||||
|
Log.WriteLine(LogLevel.Info, "Available Apps:");
|
||||||
|
getAppExecs().Values.ForEach(x => Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray())));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
Log.WriteLine(LogLevel.Error, "Exception listing managed modules: {0}", ex.ToString());
|
Log.WriteLine(LogLevel.Error, "Exception listing managed modules: {0}", ex.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
* Michael Giagnocavo <mgg@giagnocavo.net>
|
* Michael Giagnocavo <mgg@giagnocavo.net>
|
||||||
* David Brazier <David.Brazier@360crm.co.uk>
|
* David Brazier <David.Brazier@360crm.co.uk>
|
||||||
* Jeff Lenk <jlenk@frontiernet.net>
|
* Jeff Lenk <jlenk@frontiernet.net>
|
||||||
|
* Artur Kraev <ravenox@gmail.com>
|
||||||
*
|
*
|
||||||
* mod_mono.cpp -- FreeSWITCH mod_mono main class
|
* mod_mono.cpp -- FreeSWITCH mod_mono main class
|
||||||
*
|
*
|
||||||
|
@ -73,14 +74,13 @@ typedef int (*runFunction)(const char *data, void *sessionPtr);
|
||||||
typedef int (*executeFunction)(const char *cmd, void *stream, void *Event);
|
typedef int (*executeFunction)(const char *cmd, void *stream, void *Event);
|
||||||
typedef int (*executeBackgroundFunction)(const char* cmd);
|
typedef int (*executeBackgroundFunction)(const char* cmd);
|
||||||
typedef int (*reloadFunction)(const char* cmd);
|
typedef int (*reloadFunction)(const char* cmd);
|
||||||
typedef int (*listFunction)(const char* cmd);
|
|
||||||
static runFunction runDelegate;
|
static runFunction runDelegate;
|
||||||
static executeFunction executeDelegate;
|
static executeFunction executeDelegate;
|
||||||
static executeBackgroundFunction executeBackgroundDelegate;
|
static executeBackgroundFunction executeBackgroundDelegate;
|
||||||
static reloadFunction reloadDelegate;
|
static reloadFunction reloadDelegate;
|
||||||
static listFunction listDelegate;
|
static executeFunction listDelegate;
|
||||||
|
|
||||||
SWITCH_MOD_DECLARE_NONSTD(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, reloadFunction reload, listFunction list)
|
SWITCH_MOD_DECLARE_NONSTD(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, reloadFunction reload, executeFunction list)
|
||||||
{
|
{
|
||||||
runDelegate = run;
|
runDelegate = run;
|
||||||
executeDelegate = execute;
|
executeDelegate = execute;
|
||||||
|
@ -451,7 +451,7 @@ SWITCH_STANDARD_API(managedlist_api_function)
|
||||||
#ifndef _MANAGED
|
#ifndef _MANAGED
|
||||||
mono_thread_attach(globals.domain);
|
mono_thread_attach(globals.domain);
|
||||||
#endif
|
#endif
|
||||||
listDelegate(cmd);
|
listDelegate(cmd, stream, stream->param_event);
|
||||||
#ifndef _MANAGED
|
#ifndef _MANAGED
|
||||||
mono_thread_detach(mono_thread_current());
|
mono_thread_detach(mono_thread_current());
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue