* Michael Giagnocavo <mgg@giagnocavo.net>\r
* David Brazier <David.Brazier@360crm.co.uk>\r
* Jeff Lenk <jeff@jefflenk.com>\r
+ * Artur Kraev <ravenox@gmail.com>\r
* \r
* Loader.cs -- mod_managed loader\r
*\r
\r
using System;\r
using System.Collections.Generic;\r
-using System.Text;\r
using System.IO;\r
using System.Linq;\r
using System.Reflection;\r
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ExecuteDelegate(string cmd, IntPtr streamH, IntPtr eventH);\r
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ExecuteBackgroundDelegate(string cmd);\r
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool RunDelegate(string cmd, IntPtr session);\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ReloadDelegate(string cmd);\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ListDelegate(string cmd);\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ReloadDelegate(string cmd); \r
static readonly ExecuteDelegate _execute = Execute;\r
static readonly ExecuteBackgroundDelegate _executeBackground = ExecuteBackground;\r
static readonly RunDelegate _run = Run;\r
static readonly ReloadDelegate _reload = Reload;\r
- static readonly ListDelegate _list = List;\r
+ static readonly ExecuteDelegate _list = List;\r
\r
[DllImport("mod_managed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\r
- static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, ReloadDelegate reload, ListDelegate list);\r
+ static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, ReloadDelegate reload, ExecuteDelegate list);\r
\r
static readonly object loaderLock = new object();\r
\r
}\r
}\r
\r
- public static bool List(string command) {\r
- try {\r
- Log.WriteLine(LogLevel.Info, "Available APIs:");\r
- getApiExecs().Values.ForEach(x => {\r
- Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray()));\r
- });\r
- Log.WriteLine(LogLevel.Info, "Available Apps:");\r
- getAppExecs().Values.ForEach(x => {\r
- Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray()));\r
- });\r
+ public static bool List(string command, IntPtr streamHandle, IntPtr eventHandle)\r
+ {\r
+ try\r
+ {\r
+ if (streamHandle != IntPtr.Zero)\r
+ {\r
+ using (var stream = new Native.Stream(new Native.switch_stream_handle(streamHandle, false)))\r
+ {\r
+ stream.Write("Available APIs:\n");\r
+\r
+ getApiExecs().Values.ForEach(x => stream.Write(string.Format("{0}: {1}\n", x.Name, String.Join(",", x.Aliases.ToArray()))));\r
+\r
+ stream.Write("Available Apps:\n");\r
+ getAppExecs().Values.ForEach(x => stream.Write(string.Format("{0}: {1}\n", x.Name, String.Join(",", x.Aliases.ToArray()))));\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Log.WriteLine(LogLevel.Info, "Available APIs:");\r
+ getApiExecs().Values.ForEach(x => Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray())));\r
+ Log.WriteLine(LogLevel.Info, "Available Apps:");\r
+ getAppExecs().Values.ForEach(x => Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray())));\r
+ }\r
return true;\r
- } catch (Exception ex) {\r
+ }\r
+ catch (Exception ex)\r
+ {\r
Log.WriteLine(LogLevel.Error, "Exception listing managed modules: {0}", ex.ToString());\r
return false;\r
}\r
* Michael Giagnocavo <mgg@giagnocavo.net>
* David Brazier <David.Brazier@360crm.co.uk>
* Jeff Lenk <jlenk@frontiernet.net>
+ * Artur Kraev <ravenox@gmail.com>
*
* mod_mono.cpp -- FreeSWITCH mod_mono main class
*
typedef int (*executeFunction)(const char *cmd, void *stream, void *Event);
typedef int (*executeBackgroundFunction)(const char* cmd);
typedef int (*reloadFunction)(const char* cmd);
-typedef int (*listFunction)(const char* cmd);
static runFunction runDelegate;
static executeFunction executeDelegate;
static executeBackgroundFunction executeBackgroundDelegate;
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;
executeDelegate = execute;
#ifndef _MANAGED
mono_thread_attach(globals.domain);
#endif
- listDelegate(cmd);
+ listDelegate(cmd, stream, stream->param_event);
#ifndef _MANAGED
mono_thread_detach(mono_thread_current());
#endif