From: Anthony Minessale Date: Wed, 27 Mar 2013 20:51:23 +0000 (-0500) Subject: add switch_core_session_findall to get a list of all open uuid X-Git-Tag: v1.3.17-final~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14e3570848dd7e4680d954b9a76781b3d6c5dae0;p=thirdparty%2Ffreeswitch.git add switch_core_session_findall to get a list of all open uuid --- diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 21e80e28d5..1bad6377e8 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -848,7 +848,7 @@ SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(_In_ const switch_call_cause_t cause, switch_hup_type_t type); SWITCH_DECLARE(switch_console_callback_match_t *) switch_core_session_findall_matching_var(const char *var_name, const char *var_val); #define switch_core_session_hupall_matching_var(_vn, _vv, _c) switch_core_session_hupall_matching_var_ans(_vn, _vv, _c, SHT_UNANSWERED | SHT_ANSWERED) - +SWITCH_DECLARE(switch_console_callback_match_t *) switch_core_session_findall(void); /*! \brief Hangup all sessions that belong to an endpoint \param endpoint_interface The endpoint interface diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 3c0672276f..410ffa711b 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -381,6 +381,29 @@ SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause) } +SWITCH_DECLARE(switch_console_callback_match_t *) switch_core_session_findall(void) +{ + switch_hash_index_t *hi; + void *val; + switch_core_session_t *session; + switch_console_callback_match_t *my_matches = NULL; + + switch_mutex_lock(runtime.session_hash_mutex); + for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, NULL, NULL, &val); + if (val) { + session = (switch_core_session_t *) val; + if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) { + switch_console_push_match(&my_matches, session->uuid_str); + switch_core_session_rwunlock(session); + } + } + } + switch_mutex_unlock(runtime.session_hash_mutex); + + return my_matches; +} + SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(const char *uuid_str, switch_core_session_message_t *message) { switch_core_session_t *session = NULL;