summaryrefslogtreecommitdiff
path: root/res/ari
diff options
context:
space:
mode:
Diffstat (limited to 'res/ari')
-rw-r--r--res/ari/ari_websockets.c16
-rw-r--r--res/ari/internal.h22
2 files changed, 37 insertions, 1 deletions
diff --git a/res/ari/ari_websockets.c b/res/ari/ari_websockets.c
index a34e0f691..20639e12e 100644
--- a/res/ari/ari_websockets.c
+++ b/res/ari/ari_websockets.c
@@ -20,8 +20,10 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-#include "asterisk/astobj2.h"
#include "asterisk/ari.h"
+#include "asterisk/astobj2.h"
+#include "asterisk/http_websocket.h"
+#include "internal.h"
/*! \file
*
@@ -163,3 +165,15 @@ int ast_ari_websocket_session_write(struct ast_ari_websocket_session *session,
return ast_websocket_write(session->ws_session,
AST_WEBSOCKET_OPCODE_TEXT, str, strlen(str));
}
+
+void ari_handle_websocket(struct ast_websocket_server *ws_server,
+ struct ast_tcptls_session_instance *ser, const char *uri,
+ enum ast_http_method method, struct ast_variable *get_params,
+ struct ast_variable *headers)
+{
+ struct ast_http_uri fake_urih = {
+ .data = ws_server,
+ };
+ ast_websocket_uri_cb(ser, &fake_urih, uri, method, get_params,
+ headers);
+}
diff --git a/res/ari/internal.h b/res/ari/internal.h
index ffacd4939..8453747f1 100644
--- a/res/ari/internal.h
+++ b/res/ari/internal.h
@@ -25,7 +25,9 @@
* \author David M. Lee, II <dlee@digium.com>
*/
+#include "asterisk/http.h"
#include "asterisk/json.h"
+#include "asterisk/stringfields.h"
/*! @{ */
@@ -139,5 +141,25 @@ struct ast_ari_conf_user *ast_ari_config_validate_user(const char *username,
/*! @} */
+/* Forward-declare websocket structs. This avoids including http_websocket.h,
+ * which causes optional_api stuff to happen, which makes optional_api more
+ * difficult to debug. */
+
+struct ast_websocket_server;
+
+/*!
+ * \brief Wrapper for invoking the websocket code for an incoming connection.
+ *
+ * \param ws_server WebSocket server to invoke.
+ * \param ser HTTP session.
+ * \param uri Requested URI.
+ * \param method Requested HTTP method.
+ * \param get_params Parsed query parameters.
+ * \param headers Parsed HTTP headers.
+ */
+void ari_handle_websocket(struct ast_websocket_server *ws_server,
+ struct ast_tcptls_session_instance *ser, const char *uri,
+ enum ast_http_method method, struct ast_variable *get_params,
+ struct ast_variable *headers);
#endif /* ARI_INTERNAL_H_ */