*/
SWITCH_DECLARE(void) switch_core_session_hupall(_In_ switch_call_cause_t cause);
+typedef enum {
+ SHT_NONE = 0,
+ SHT_UNANSWERED = (1 << 0),
+ SHT_ANSWERED = (1 << 1)
+} switch_hup_type_t;
+
/*!
\brief Hangup all sessions which match a specific channel variable
\param var_name The variable name to look for
\param var_val The value to look for
\param cause the hangup cause to apply to the hungup channels
*/
-SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(_In_ const char *var_name, _In_ const char *var_val, _In_ switch_call_cause_t cause);
+SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(_In_ const char *var_name, _In_ const char *var_val, _In_
+ 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)
/*!
\brief Hangup all sessions that belong to an endpoint
}
}
-
-static void kickall_matching_var(conference_obj_t *conference, const char *var, const char *val)
+#if 0
+static uint32_t kickall_matching_var(conference_obj_t *conference, const char *var, const char *val)
{
conference_member_t *member = NULL;
const char *vval = NULL;
+ uint32_t r = 0;
+
switch_mutex_lock(conference->mutex);
switch_mutex_lock(conference->member_mutex);
if (vval && !strcmp(vval, val)) {
switch_set_flag_locked(member, MFLAG_KICKED);
switch_clear_flag_locked(member, MFLAG_RUNNING);
- switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
+ switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
+ r++;
}
}
switch_mutex_unlock(conference->member_mutex);
switch_mutex_unlock(conference->mutex);
+
+ return r;
}
+#endif
static void call_setup_event_handler(switch_event_t *event)
{
}
} else if (!strcasecmp(action, "end")) {
- //switch_core_session_hupall_matching_var("conference_call_key", key, SWITCH_CAUSE_NORMAL_CLEARING);
- kickall_matching_var(conference, "conference_call_key", key);
+ if (switch_core_session_hupall_matching_var("conference_call_key", key, SWITCH_CAUSE_NORMAL_CLEARING)) {
+ send_conference_notify(conference, "SIP/2.0 200 OK\r\n", call_id, SWITCH_TRUE);
+ } else {
+ send_conference_notify(conference, "SIP/2.0 481 Failure\r\n", call_id, SWITCH_TRUE);
+ }
status = SWITCH_STATUS_SUCCESS;
}
struct str_node *next;
};
-SWITCH_DECLARE(void) switch_core_session_hupall_matching_var(const char *var_name, const char *var_val, switch_call_cause_t cause)
+SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(const char *var_name, const char *var_val, switch_call_cause_t cause,
+ switch_hup_type_t type)
{
switch_hash_index_t *hi;
void *val;
switch_core_session_t *session;
switch_memory_pool_t *pool;
struct str_node *head = NULL, *np;
+ uint32_t r = 0;
switch_core_new_memory_pool(&pool);
if (!var_val)
- return;
+ return r;
switch_mutex_lock(runtime.session_hash_mutex);
for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
if (val) {
session = (switch_core_session_t *) val;
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
- np = switch_core_alloc(pool, sizeof(*np));
- np->str = switch_core_strdup(pool, session->uuid_str);
- np->next = head;
- head = np;
+ int ans = switch_channel_test_flag(switch_core_session_get_channel(session), CF_ANSWERED);
+ if ((ans && (type & SHT_ANSWERED)) || (!ans && (type & SHT_UNANSWERED))) {
+ np = switch_core_alloc(pool, sizeof(*np));
+ np->str = switch_core_strdup(pool, session->uuid_str);
+ np->next = head;
+ head = np;
+ }
switch_core_session_rwunlock(session);
}
}
if (switch_channel_up_nosig(session->channel) &&
(this_val = switch_channel_get_variable(session->channel, var_name)) && (!strcmp(this_val, var_val))) {
switch_channel_hangup(session->channel, cause);
+ r++;
}
switch_core_session_rwunlock(session);
}
switch_core_destroy_memory_pool(&pool);
+ return r;
}