res_stasis: Add ability to switch applications.

Added the ability to move between Stasis applications within Stasis.
This can be done by calling 'move' in an application, providing (at
minimum) the channel's id and the application to switch to. If the
application is not registered or active, nothing will happen and the
channel will remain in the current application, and an event will be
triggered to let the application know that the move failed. The event
name is "ApplicationMoveFailed", and provides the "destination" that the
channel was attempting to move to, as well as the usual channel
information. Optionally, a list of arguments can be passed to the
function call for the receiving application. A full example of a 'move'
call would look like this:

client.channels.move(channelId, app, appArgs)

The control object used to control the channel in Stasis can now switch
which application it belongs to, rather than belonging to one Stasis
application for its lifetime. This allows us to use the same control
object instead of having to tear down the current one and create
another.

ASTERISK-28267 #close

Change-Id: I43d12b10045a98a8d42541889b85695be26f288a
This commit is contained in:
Ben Ford
2019-03-07 07:41:14 -06:00
parent 24b94aa27f
commit 50a4b618fc
12 changed files with 703 additions and 14 deletions

View File

@@ -623,6 +623,24 @@ int ast_ari_validate_mailbox(struct ast_json *json);
*/
ari_validator ast_ari_validate_mailbox_fn(void);
/*!
* \brief Validator for ApplicationMoveFailed.
*
* Notification that trying to move a channel to another Stasis application failed.
*
* \param json JSON object to validate.
* \returns True (non-zero) if valid.
* \returns False (zero) if invalid.
*/
int ast_ari_validate_application_move_failed(struct ast_json *json);
/*!
* \brief Function pointer to ast_ari_validate_application_move_failed().
*
* See \ref ast_ari_model_validators.h for more details.
*/
ari_validator ast_ari_validate_application_move_failed_fn(void);
/*!
* \brief Validator for ApplicationReplaced.
*
@@ -1527,6 +1545,14 @@ ari_validator ast_ari_validate_application_fn(void);
* - name: string (required)
* - new_messages: int (required)
* - old_messages: int (required)
* ApplicationMoveFailed
* - asterisk_id: string
* - type: string (required)
* - application: string (required)
* - timestamp: Date
* - args: List[string] (required)
* - channel: Channel (required)
* - destination: string (required)
* ApplicationReplaced
* - asterisk_id: string
* - type: string (required)