]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add switch_core_session_findall to get a list of all open uuid
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Mar 2013 20:51:23 +0000 (15:51 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 27 Mar 2013 20:51:23 +0000 (15:51 -0500)
src/include/switch_core.h
src/switch_core_session.c

index 21e80e28d516787023e7a2b306903944088d4a27..1bad6377e83dd0a68518fbddfe8a7d00bd0924bb 100644 (file)
@@ -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 
index 3c0672276fef51e522d0272a18661e3d7749a4b2..410ffa711b71e678bf554f2dcabdf93193f1c46f 100644 (file)
@@ -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;