diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 9335cab6a7..0d1a0f66e1 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1279,8 +1279,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi number = argv[1]; } - - + if (!switch_strlen_zero(name)) { char message[256] = ""; const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent"); @@ -1290,32 +1289,39 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi number = tech_pvt->caller_profile->destination_number; } - if (ua && switch_stristr("snom", ua)) { - snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", name, number); - nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), - SIPTAG_PAYLOAD_STR(message), TAG_END()); - } else if ((ua && (switch_stristr("polycom", ua) || - switch_stristr("UPDATE", tech_pvt->x_actually_support_remote)))) { - snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number); - nua_update(tech_pvt->nh, - TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)), - TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), - TAG_END()); - } - - - - if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) { - const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "SEND"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Name", name); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Number", number); - if (uuid) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid); + if (switch_strlen_zero(tech_pvt->last_sent_callee_id_name) || strcmp(tech_pvt->last_sent_callee_id_name, name) || + switch_strlen_zero(tech_pvt->last_sent_callee_id_number) || strcmp(tech_pvt->last_sent_callee_id_number, number)) { + + if (ua && switch_stristr("snom", ua)) { + snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", name, number); + nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"), + TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + SIPTAG_PAYLOAD_STR(message), TAG_END()); + } else if ((ua && (switch_stristr("polycom", ua) || + switch_stristr("UPDATE", tech_pvt->x_actually_support_remote)))) { + snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number); + nua_update(tech_pvt->nh, + TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)), + TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), + TAG_END()); } - switch_channel_event_set_data(channel, event); - switch_event_fire(&event); + + tech_pvt->last_sent_callee_id_name = switch_core_session_strdup(tech_pvt->session, name); + tech_pvt->last_sent_callee_id_number = switch_core_session_strdup(tech_pvt->session, number); + + if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) { + const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "SEND"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Name", name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Callee-Number", number); + if (uuid) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid); + } + switch_channel_event_set_data(channel, event); + switch_event_fire(&event); + } + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Not sending same id again \"%s\" <%s>\n", name, number); } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 48d67e26b0..19c0df841b 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -583,6 +583,8 @@ struct private_object { char *route_uri; char *x_actually_support_remote; char *x_actually_support_local; + char *last_sent_callee_id_name; + char *last_sent_callee_id_number; switch_port_t stun_port; uint32_t stun_flags; unsigned long rm_rate; diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 269a3f9d51..b5d23afe9f 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -432,9 +432,7 @@ SWITCH_STANDARD_APP(socket_function) switch_ivr_park(session, NULL); - if (switch_core_session_private_event_count(session)) { - switch_ivr_parse_all_events(session); - } + switch_ivr_parse_all_events(session); if (switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, "socket_resume")) && switch_true(var))) { switch_channel_set_state(channel, CS_EXECUTE); diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index d37af73084..9f1fc62fe2 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -298,6 +298,8 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK); } + switch_ivr_parse_all_messages(session_a); + if (!inner_bridge && (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND))) { status = switch_core_session_read_frame(session_a, &read_frame, SWITCH_IO_FLAG_NONE, stream_id);