presence tweaks for conference/fifo/parking
This commit is contained in:
parent
ea359d899f
commit
caa360b6d2
|
@ -430,6 +430,7 @@ static switch_status_t conference_say(conference_obj_t *conference, const char *
|
|||
static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim);
|
||||
static conference_obj_t *conference_find(char *name);
|
||||
static void member_bind_controls(conference_member_t *member, const char *controls);
|
||||
static void conference_send_presence(conference_obj_t *conference);
|
||||
|
||||
SWITCH_STANDARD_API(conf_api_main);
|
||||
|
||||
|
@ -893,25 +894,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
|
|||
if (conference->end_count++);
|
||||
}
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||
if (strchr(conference->name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", conference->name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
}
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", conference->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", conference->count == 1 ? "early" : "confirmed");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", conference->count == 1 ? "outbound" : "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
conference_send_presence(conference);
|
||||
|
||||
channel = switch_core_session_get_channel(member->session);
|
||||
switch_channel_set_variable_printf(channel, "conference_member_id", "%d", member->id);
|
||||
|
@ -1119,25 +1102,7 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe
|
|||
}
|
||||
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||
if (strchr(conference->name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", conference->name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
}
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", conference->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", conference->count == 1 ? "early" : "confirmed");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", conference->count == 1 ? "outbound" : "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
conference_send_presence(conference);
|
||||
|
||||
if ((conference->min && switch_test_flag(conference, CFLAG_ENFORCE_MIN) && conference->count < conference->min)
|
||||
|| (switch_test_flag(conference, CFLAG_DYNAMIC) && conference->count == 0)) {
|
||||
|
@ -1718,26 +1683,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
|||
}
|
||||
}
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||
if (strchr(conference->name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", conference->name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
}
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Inactive");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", conference->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
conference_send_presence(conference);
|
||||
|
||||
switch_mutex_lock(conference->mutex);
|
||||
conference_stop_file(conference, FILE_STOP_ASYNC);
|
||||
|
@ -7205,31 +7151,75 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
|
|||
return conference;
|
||||
}
|
||||
|
||||
static void conference_send_presence(conference_obj_t *conference)
|
||||
{
|
||||
switch_event_t *event;
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||
if (strchr(conference->name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", conference->name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
}
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", conference->name);
|
||||
|
||||
if (conference->count) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", conference->count == 1 ? "early" : "confirmed");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", conference->count == 1 ? "outbound" : "inbound");
|
||||
} else {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Inactive");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void pres_event_handler(switch_event_t *event)
|
||||
{
|
||||
char *to = switch_event_get_header(event, "to");
|
||||
char *dup_to = NULL, *conf_name;
|
||||
char *domain_name = NULL;
|
||||
char *dup_to = NULL, *conf_name, *dup_conf_name = NULL;
|
||||
conference_obj_t *conference;
|
||||
|
||||
if (!to || strncasecmp(to, "conf+", 5)) {
|
||||
if (!to || strncasecmp(to, "conf+", 5) || !strchr(to, '@')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(dup_to = strdup(to))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
conf_name = dup_to + 5;
|
||||
|
||||
if ((conference = conference_find(conf_name))) {
|
||||
if ((domain_name = strchr(conf_name, '@'))) {
|
||||
*domain_name++ = '\0';
|
||||
}
|
||||
|
||||
dup_conf_name = switch_mprintf("%q@%q", conf_name, domain_name);
|
||||
|
||||
|
||||
if ((conference = conference_find(conf_name)) || (conference = conference_find(dup_conf_name))) {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||
if (strchr(conference->name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", conference->name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
}
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
|
@ -7258,6 +7248,7 @@ static void pres_event_handler(switch_event_t *event)
|
|||
}
|
||||
|
||||
switch_safe_free(dup_to);
|
||||
switch_safe_free(dup_conf_name);
|
||||
}
|
||||
|
||||
static void send_presence(switch_event_types_t id)
|
||||
|
|
|
@ -311,6 +311,7 @@ struct fifo_node {
|
|||
outbound_strategy_t outbound_strategy;
|
||||
int ring_timeout;
|
||||
int default_lag;
|
||||
char *domain_name;
|
||||
};
|
||||
|
||||
typedef struct fifo_node fifo_node_t;
|
||||
|
@ -814,7 +815,8 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
|
|||
char outbound_count[80] = "";
|
||||
callback_t cbt = { 0 };
|
||||
char *sql = NULL;
|
||||
|
||||
char *domain_name = NULL;
|
||||
|
||||
if (!globals.running) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -826,6 +828,12 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
|
|||
node->pool = pool;
|
||||
node->outbound_strategy = default_strategy;
|
||||
node->name = switch_core_strdup(node->pool, name);
|
||||
|
||||
if (!strchr(name, '@')) {
|
||||
domain_name = switch_core_get_variable_dup("domain");
|
||||
node->domain_name = switch_core_strdup(node->pool, domain_name);
|
||||
}
|
||||
|
||||
for (x = 0; x < MAX_PRI; x++) {
|
||||
fifo_queue_create(&node->fifo_list[x], 1000, node->pool);
|
||||
switch_assert(node->fifo_list[x]);
|
||||
|
@ -849,6 +857,9 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
|
|||
switch_mutex_lock(globals.mutex);
|
||||
switch_core_hash_insert(globals.fifo_hash, name, node);
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
switch_safe_free(domain_name);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -1929,8 +1940,15 @@ static void send_presence(fifo_node_t *node)
|
|||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "queue");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", node->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", node->name);
|
||||
|
||||
if (node->domain_name) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s@%s", node->name, node->domain_name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", node->name, node->domain_name);
|
||||
} else {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", node->name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", node->name);
|
||||
}
|
||||
|
||||
if ((wait_count = node_caller_count(node)) > 0) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d waiting)", wait_count);
|
||||
} else {
|
||||
|
@ -1952,25 +1970,34 @@ static void send_presence(fifo_node_t *node)
|
|||
static void pres_event_handler(switch_event_t *event)
|
||||
{
|
||||
char *to = switch_event_get_header(event, "to");
|
||||
char *dup_to = NULL, *node_name;
|
||||
char *domain_name = NULL;
|
||||
char *dup_to = NULL, *node_name , *dup_node_name;
|
||||
fifo_node_t *node;
|
||||
|
||||
if (!globals.running) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!to || strncasecmp(to, "queue+", 5)) {
|
||||
if (!to || strncasecmp(to, "queue+", 6) || !strchr(to, '@')) {
|
||||
return;
|
||||
}
|
||||
|
||||
dup_to = strdup(to);
|
||||
switch_assert(dup_to);
|
||||
|
||||
node_name = dup_to + 5;
|
||||
node_name = dup_to + 6;
|
||||
|
||||
if ((domain_name = strchr(node_name, '@'))) {
|
||||
*domain_name++ = '\0';
|
||||
}
|
||||
|
||||
dup_node_name = switch_mprintf("%q@%q", node_name, domain_name);
|
||||
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
if (!(node = switch_core_hash_find(globals.fifo_hash, node_name))) {
|
||||
if (!(node = switch_core_hash_find(globals.fifo_hash, node_name)) && !(node = switch_core_hash_find(globals.fifo_hash, dup_node_name))) {
|
||||
node = create_node(node_name, 0, globals.sql_mutex);
|
||||
node->domain_name = switch_core_strdup(node->pool, domain_name);
|
||||
node->ready = 1;
|
||||
}
|
||||
|
||||
|
@ -1979,6 +2006,7 @@ static void pres_event_handler(switch_event_t *event)
|
|||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
switch_safe_free(dup_to);
|
||||
switch_safe_free(dup_node_name);
|
||||
}
|
||||
|
||||
static uint32_t fifo_add_outbound(const char *node_name, const char *url, uint32_t priority)
|
||||
|
|
|
@ -53,6 +53,7 @@ typedef struct {
|
|||
switch_mutex_t *mutex;
|
||||
switch_memory_pool_t *pool;
|
||||
time_t last_timeout_check;
|
||||
char *name;
|
||||
} valet_lot_t;
|
||||
|
||||
static valet_lot_t globals = { 0 };
|
||||
|
@ -66,6 +67,7 @@ static valet_lot_t *valet_find_lot(const char *name, switch_bool_t create)
|
|||
lot = switch_core_hash_find(globals.hash, name);
|
||||
if (!lot && create) {
|
||||
switch_zmalloc(lot, sizeof(*lot));
|
||||
lot->name = strdup(name);
|
||||
switch_mutex_init(&lot->mutex, SWITCH_MUTEX_NESTED, globals.pool);
|
||||
switch_core_hash_init(&lot->hash, NULL);
|
||||
switch_core_hash_insert(globals.hash, name, lot);
|
||||
|
@ -222,12 +224,16 @@ static int EC = 0;
|
|||
static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_token_t *token, switch_bool_t in)
|
||||
{
|
||||
|
||||
char *domain_name, *dup_domain_name = NULL;
|
||||
char *domain_name, *dup_lot_name = NULL, *dup_domain_name = NULL;
|
||||
switch_event_t *event;
|
||||
int count;
|
||||
|
||||
if ((domain_name = strchr(lot_name, '@'))) {
|
||||
domain_name++;
|
||||
|
||||
dup_lot_name = strdup(lot_name);
|
||||
lot_name = dup_lot_name;
|
||||
|
||||
if ((domain_name = strchr(dup_lot_name, '@'))) {
|
||||
*domain_name++ = '\0';
|
||||
}
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
|
@ -245,11 +251,8 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
|
|||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||
if (strchr(lot_name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", lot_name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
}
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", count, count == 1 ? "" : "s");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
|
||||
|
@ -266,11 +269,8 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
|
|||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||
if (strchr(lot_name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", lot_name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
}
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
||||
|
@ -322,6 +322,7 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
|
|||
}
|
||||
|
||||
switch_safe_free(dup_domain_name);
|
||||
switch_safe_free(dup_lot_name);
|
||||
|
||||
}
|
||||
|
||||
|
@ -639,11 +640,11 @@ SWITCH_STANDARD_API(valet_info_function)
|
|||
static void pres_event_handler(switch_event_t *event)
|
||||
{
|
||||
char *to = switch_event_get_header(event, "to");
|
||||
char *dup_to = NULL, *lot_name, *domain_name, *dup_domain_name = NULL;
|
||||
char *dup_to = NULL, *lot_name, *dup_lot_name = NULL, *domain_name;
|
||||
valet_lot_t *lot;
|
||||
|
||||
|
||||
if (!to || strncasecmp(to, "park+", 5)) {
|
||||
int found = 0;
|
||||
|
||||
if (!to || strncasecmp(to, "park+", 5) || !strchr(to, '@')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -654,31 +655,21 @@ static void pres_event_handler(switch_event_t *event)
|
|||
lot_name = dup_to + 5;
|
||||
|
||||
if ((domain_name = strchr(lot_name, '@'))) {
|
||||
domain_name++;
|
||||
*domain_name++ = '\0';
|
||||
}
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
dup_domain_name = switch_core_get_variable_dup("domain");
|
||||
domain_name = dup_domain_name;
|
||||
}
|
||||
dup_lot_name = switch_mprintf("%q@%q", lot_name, domain_name);
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
domain_name = "cluecon.com";
|
||||
}
|
||||
|
||||
if ((lot = valet_find_lot(lot_name, SWITCH_FALSE))) {
|
||||
if ((lot = valet_find_lot(lot_name, SWITCH_FALSE)) || (dup_lot_name && (lot = valet_find_lot(dup_lot_name, SWITCH_FALSE)))) {
|
||||
int count = valet_lot_count(lot);
|
||||
|
||||
|
||||
if (count) {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||
if (strchr(lot_name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", lot_name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
}
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", count, count == 1 ? "" : "s");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
|
@ -690,15 +681,12 @@ static void pres_event_handler(switch_event_t *event)
|
|||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
found++;
|
||||
}
|
||||
} else {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||
if (strchr(lot_name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", lot_name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
}
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
||||
|
@ -718,32 +706,35 @@ static void pres_event_handler(switch_event_t *event)
|
|||
switch_hash_index_t *hi;
|
||||
const void *var;
|
||||
void *val;
|
||||
const char *nvar;
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
for (hi = switch_hash_first(NULL, globals.hash); hi; hi = switch_hash_next(hi)) {
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
switch_console_push_match(&matches, (const char *) var);
|
||||
nvar = (const char *) var;
|
||||
|
||||
if (!strchr(nvar, '@') || switch_stristr(domain_name, nvar)) {
|
||||
switch_console_push_match(&matches, nvar);
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
if (matches) {
|
||||
valet_token_t *token;
|
||||
|
||||
for (m = matches->head; m; m = m->next) {
|
||||
for (m = matches->head; !found && m; m = m->next) {
|
||||
lot = valet_find_lot(m->val, SWITCH_FALSE);
|
||||
switch_mutex_lock(lot->mutex);
|
||||
|
||||
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, lot_name))) {
|
||||
|
||||
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, lot_name)) && !token->timeout) {
|
||||
found++;
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||
if (strchr(lot_name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", lot_name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
}
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Active");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", token->bridged == 0 ? "Holding" : "Active");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
|
@ -758,18 +749,14 @@ static void pres_event_handler(switch_event_t *event)
|
|||
switch_mutex_unlock(lot->mutex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
if (!found && switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||
if (strchr(lot_name, '@')) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", lot_name);
|
||||
} else {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
}
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
|
@ -783,7 +770,7 @@ static void pres_event_handler(switch_event_t *event)
|
|||
}
|
||||
|
||||
switch_safe_free(dup_to);
|
||||
switch_safe_free(dup_domain_name);
|
||||
switch_safe_free(dup_lot_name);
|
||||
}
|
||||
|
||||
/* Macro expands to: switch_status_t mod_valet_parking_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
|
||||
|
|
Loading…
Reference in New Issue