mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-10 22:31:57 +00:00
Add simple managedlist function to print out loaded APIs/Apps
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Michael Giagnocavo <mgg@packetrino.com>
|
||||
* Michael Giagnocavo <mgg@giagnocavo.net>
|
||||
* David Brazier <David.Brazier@360crm.co.uk>
|
||||
* Jeff Lenk <jlenk@frontiernet.net>
|
||||
*
|
||||
@@ -55,6 +55,7 @@ SWITCH_STANDARD_API(managedrun_api_function); /* ExecuteBackground */
|
||||
SWITCH_STANDARD_API(managed_api_function); /* Execute */
|
||||
SWITCH_STANDARD_APP(managed_app_function); /* Run */
|
||||
SWITCH_STANDARD_API(managedreload_api_function); /* Reload */
|
||||
SWITCH_STANDARD_API(managedlist_api_function); /* List modules */
|
||||
|
||||
#define MOD_MANAGED_ASM_NAME "FreeSWITCH.Managed"
|
||||
#define MOD_MANAGED_ASM_V1 1
|
||||
@@ -72,19 +73,23 @@ typedef int (*runFunction)(const char *data, void *sessionPtr);
|
||||
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;
|
||||
|
||||
SWITCH_MOD_DECLARE_NONSTD(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, reloadFunction reload)
|
||||
SWITCH_MOD_DECLARE_NONSTD(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, reloadFunction reload, listFunction list)
|
||||
{
|
||||
runDelegate = run;
|
||||
executeDelegate = execute;
|
||||
executeBackgroundDelegate = executeBackground;
|
||||
reloadDelegate = reload;
|
||||
listDelegate = list;
|
||||
}
|
||||
|
||||
|
||||
// Sets up delegates (and anything else needed) on the ManagedSession object
|
||||
// Called from ManagedSession.Initialize Managed -> this is Unmanaged code so all pointers are marshalled and prevented from GC
|
||||
// Exported method.
|
||||
@@ -361,6 +366,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_managed_load)
|
||||
SWITCH_ADD_API(api_interface, "managed", "Run a module as an API function (Execute)", managed_api_function, "<module> [<args>]");
|
||||
SWITCH_ADD_APP(app_interface, "managed", "Run CLI App", "Run an App on a channel", managed_app_function, "<modulename> [<args>]", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_API(api_interface, "managedreload", "Force [re]load of a file", managedreload_api_function, "<filename>");
|
||||
SWITCH_ADD_API(api_interface, "managedlist", "Log the list of available APIs and Apps", managedlist_api_function, "");
|
||||
return SWITCH_STATUS_NOUNLOAD;
|
||||
}
|
||||
|
||||
@@ -440,4 +446,16 @@ SWITCH_STANDARD_API(managedreload_api_function)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(managedlist_api_function)
|
||||
{
|
||||
#ifndef _MANAGED
|
||||
mono_thread_attach(globals.domain);
|
||||
#endif
|
||||
listDelegate(cmd);
|
||||
#ifndef _MANAGED
|
||||
mono_thread_detach(mono_thread_current());
|
||||
#endif
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
Reference in New Issue
Block a user