diff options
author | Matt Jordan <mjordan@digium.com> | 2015-05-17 20:36:41 -0500 |
---|---|---|
committer | Matt Jordan <mjordan@digium.com> | 2015-05-22 11:13:34 -0500 |
commit | 9cffcca5f97d74d88e0114f588590db27aac421b (patch) | |
tree | 5f92a4f1e7c8ca2d363de0ef1611d995c160e490 /rest-api-templates/ari_resource.h.mustache | |
parent | d7086a27b46a6e7965656138194af0a27e9e25d8 (diff) |
res/ari: Register Stasis application on WebSocket attempt
Prior to this patch, when a WebSocket connection is made, ARI would not
be informed of the connection until after the WebSocket layer had
accepted the connection. This created a brief race condition where the
ARI client would be notified that it was connected, a channel would be
sent into the Stasis dialplan application, but ARI would not yet have
registered the Stasis application presented in the HTTP request that
established the WebSocket.
This patch resolves this issue by doing the following:
* When a WebSocket attempt is made, a callback is made into the ARI
application layer, which verifies and registers the apps presented in
the HTTP request. Because we do not yet have a WebSocket, we cannot
have an event session for the corresponding applications. Some
defensive checks were thus added to make the application objects
tolerant to a NULL event session.
* When a WebSocket connection is made, the registered application is
updated with the newly created event session that wraps the WebSocket
connection.
ASTERISK-24988 #close
Reported by: Joshua Colp
Change-Id: Ia5dc60dc2b6bee76cd5aff0f69dd53b36e83f636
Diffstat (limited to 'rest-api-templates/ari_resource.h.mustache')
-rw-r--r-- | rest-api-templates/ari_resource.h.mustache | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/rest-api-templates/ari_resource.h.mustache b/rest-api-templates/ari_resource.h.mustache index 3a20776a7..d3f40b6bd 100644 --- a/rest-api-templates/ari_resource.h.mustache +++ b/rest-api-templates/ari_resource.h.mustache @@ -89,6 +89,23 @@ int ast_ari_{{c_name}}_{{c_nickname}}_parse_body( void ast_ari_{{c_name}}_{{c_nickname}}(struct ast_variable *headers, struct ast_ari_{{c_name}}_{{c_nickname}}_args *args, struct ast_ari_response *response); {{/is_req}} {{#is_websocket}} + +/*! + * \brief {{summary}} +{{#notes}} + * + * {{{notes}}} +{{/notes}} + * + * \param ser HTTP TCP/TLS Server Session + * \param headers HTTP headers + * \param args Swagger parameters + * + * \retval 0 success + * \retval non-zero error + */ +int ast_ari_websocket_{{c_name}}_{{c_nickname}}_attempted(struct ast_tcptls_session_instance *ser, struct ast_variable *headers, struct ast_ari_{{c_name}}_{{c_nickname}}_args *args); + /*! * \brief {{summary}} {{#notes}} @@ -100,7 +117,7 @@ void ast_ari_{{c_name}}_{{c_nickname}}(struct ast_variable *headers, struct ast_ * \param headers HTTP headers. * \param args Swagger parameters. */ -void ast_ari_websocket_{{c_name}}_{{c_nickname}}(struct ast_ari_websocket_session *session, struct ast_variable *headers, struct ast_ari_{{c_name}}_{{c_nickname}}_args *args); +void ast_ari_websocket_{{c_name}}_{{c_nickname}}_established(struct ast_ari_websocket_session *session, struct ast_variable *headers, struct ast_ari_{{c_name}}_{{c_nickname}}_args *args); {{/is_websocket}} {{/operations}} {{/apis}} |