diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 1fc29680ea..4262f90b77 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -302,6 +302,7 @@ typedef enum { SWITCH_MESSAGE_INDICATE_NOMEDIA - indicate no-media is required SWITCH_MESSAGE_INDICATE_HOLD - indicate hold SWITCH_MESSAGE_INDICATE_UNHOLD - indicate unhold + SWITCH_MESSAGE_INDICATE_REDIRECT - indicate redirect */ typedef enum { @@ -316,6 +317,7 @@ typedef enum { SWITCH_MESSAGE_INDICATE_NOMEDIA, SWITCH_MESSAGE_INDICATE_HOLD, SWITCH_MESSAGE_INDICATE_UNHOLD, + SWITCH_MESSAGE_INDICATE_REDIRECT } switch_core_session_message_types_t; diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index f3bf243026..69c087402c 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -153,6 +153,20 @@ static void answer_function(switch_core_session_t *session, char *data) switch_channel_answer(channel); } +static void redirect_function(switch_core_session_t *session, char *data) +{ + switch_core_session_message_t msg = {0}; + + /* Tell the channel to redirect */ + msg.from = __FILE__; + msg.string_arg = data; + msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT; + switch_core_session_receive_message(session, &msg); + +} + + + static void set_function(switch_core_session_t *session, char *data) { switch_channel_t *channel; @@ -455,13 +469,22 @@ static switch_api_interface_t presence_api_interface = { /*.next */ &dptools_api_interface }; +static const switch_application_interface_t redirect_application_interface = { + /*.interface_name */ "redirect", + /*.application_function */ redirect_function, + /* long_desc */ "Send a redirect message to a session.", + /* short_desc */ "Send session redirect", + /* syntax */ "", + /*.next */ NULL +}; + static const switch_application_interface_t ivr_application_interface = { /*.interface_name */ "ivr", /*.application_function */ ivr_application_function, /* long_desc */ "Run an ivr menu.", /* short_desc */ "Run an ivr menu", /* syntax */ "", - /*.next */ NULL + /*.next */ &redirect_application_interface }; static const switch_application_interface_t detect_speech_application_interface = { diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 6683f5c4fb..b526ae8c13 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1885,6 +1885,12 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-activate timed RTP!\n"); } break; + case SWITCH_MESSAGE_INDICATE_REDIRECT: + if(msg->string_arg) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Re-directing to %s\n", msg->string_arg); + nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END()); + } + break; case SWITCH_MESSAGE_INDICATE_RINGING: nua_respond(tech_pvt->nh, SIP_180_RINGING, SIPTAG_CONTACT_STR(tech_pvt->profile->url), TAG_END()); break;