Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENGDESK-33432: Create SWITCH_EVENT_SEND_INFO event #310

Open
wants to merge 2 commits into
base: telnyx/telephony/development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/mod/endpoints/mod_sofia/mod_sofia.c
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (ok) {
char *headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_INFO_HEADER_PREFIX);
const char *pl = NULL;
switch_event_t *event;

if (!zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) {
switch_snprintf(ct, sizeof(ct), "%s/%s", msg->string_array_arg[0], msg->string_array_arg[1]);
Expand All @@ -2156,6 +2157,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
TAG_END());

switch_safe_free(headers);

switch_channel_set_variable(channel, "sip_info_content_type", ct);
switch_channel_set_variable(channel, "sip_info_pl_data", pl);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send_info is not supported.\n", switch_channel_get_name(channel));
}
Expand Down Expand Up @@ -6100,6 +6104,10 @@ void general_event_handler(switch_event_t *event)
char buf[1024] = "";
char *p;

if (switch_true(switch_event_get_header(event, "message-indicate-info-event"))) {
goto done;
}

if (!profile_name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Profile Name\n");
goto done;
Expand Down
12 changes: 12 additions & 0 deletions src/mod/endpoints/mod_sofia/sofia.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,19 @@ static void our_sofia_event_callback(nua_event_t event,
switch (event) {
case nua_r_get_params:
case nua_i_fork:
break;
case nua_r_info:
if (channel) {
switch_event_t *s_event;

if (switch_event_create(&s_event, SWITCH_EVENT_SEND_INFO) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(channel, s_event);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "message-indicate-info-event", "true");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "content-type", switch_channel_get_variable(channel, "sip_info_content_type"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baloeng please correct the indentation here, rest looks good

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tajamulTelnyx There's actually no indentation issue here. Just that the text was wrapped by github so it could fit to this page.

If you view the file as a whole, you wouldn't see this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it :(

switch_event_add_body(s_event, "%s", switch_channel_get_variable(channel, "sip_info_pl_data"));
switch_event_fire(&s_event);
}
}
break;
case nua_r_unregister:
if (gateway && status != 401 && status != 407 && status >= 200) {
Expand Down