add switch_core_session_findall to get a list of all open uuid

This commit is contained in:
Anthony Minessale 2013-03-27 15:51:23 -05:00
parent b4e21fd3f6
commit 14e3570848
2 changed files with 24 additions and 1 deletions

View 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

View 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;