Asterisk - The Open Source Telephony Project GIT-master-8924258
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
ari_websockets.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013, Digium, Inc.
5 *
6 * David M. Lee, II <dlee@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19#ifndef ARI_WEBSOCKETS_H_
20#define ARI_WEBSOCKETS_H_
21
22/*! \file
23 *
24 * \brief Internal API's for websockets.
25 * \author David M. Lee, II <dlee@digium.com>
26 */
27
28#include "asterisk/http.h"
29#include "asterisk/json.h"
30#include "asterisk/vector.h"
31
33
34/* Forward-declare websocket structs. This avoids including http_websocket.h,
35 * which causes optional_api stuff to happen, which makes optional_api more
36 * difficult to debug. */
37
38//struct ast_websocket_server;
39struct ast_websocket;
40
42 struct ast_websocket *ast_ws_session; /*!< The parent websocket session. */
43 int (*validator)(struct ast_json *); /*!< The message validator. */
44 struct ao2_container *websocket_apps; /*!< List of Stasis apps registered to
45 the websocket session. */
46 AST_VECTOR(, struct ast_json *) message_queue; /*!< Container for holding delayed messages. */
47 char *app_name; /*!< The name of the Stasis application. */
48 char session_id[]; /*!< The id for the websocket session. */
49};
50
51/*!
52 * \internal
53 * \brief Send a JSON event to a websocket.
54 *
55 * \param ari_ws_session ARI websocket session
56 * \param app_name Application name
57 * \param message JSON message
58 * \param debug_app Debug flag for application
59 */
61 const char *app_name, struct ast_json *message, int debug_app);
62
63/*!
64 * \internal
65 * \brief Process an ARI REST over Websocket request
66 *
67 * \param ari_ws_session ARI websocket session
68 * \param remote_addr Remote address for log messages
69 * \param upgrade_headers HTTP headers from the upgrade request
70 * \param app_name Application name
71 * \param msg JSON Request message
72 * \retval 0 on success, -1 on failure
73 */
74int ari_websocket_process_request(struct ari_ws_session *ast_ws_session,
75 const char *remote_addr, struct ast_variable *upgrade_headers,
76 const char *app_name, struct ast_json *msg);
77
78/*!
79 * \brief Wrapper for invoking the websocket code for an incoming connection.
80 *
81 * \param ws_server WebSocket server to invoke.
82 * \param ser HTTP session.
83 * \param uri Requested URI.
84 * \param method Requested HTTP method.
85 * \param get_params Parsed query parameters.
86 * \param headers Parsed HTTP headers.
87 */
89 const char *uri, enum ast_http_method method,
90 struct ast_variable *get_params,
91 struct ast_variable *headers);
92
95
96#endif /* ARI_WEBSOCKETS_H_ */
int ari_websocket_process_request(struct ari_ws_session *ast_ws_session, const char *remote_addr, struct ast_variable *upgrade_headers, const char *app_name, struct ast_json *msg)
void ari_websocket_send_event(struct ari_ws_session *ari_ws_session, const char *app_name, struct ast_json *message, int debug_app)
Callback handler for Stasis application messages.
int ari_websocket_unload_module(void)
void ari_handle_websocket(struct ast_tcptls_session_instance *ser, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers)
Wrapper for invoking the websocket code for an incoming connection.
int ari_websocket_load_module(void)
Support for Private Asterisk HTTP Servers.
ast_http_method
HTTP Request methods known by Asterisk.
Definition: http.h:58
Asterisk JSON abstraction layer.
const char * app_name(struct ast_app *app)
Definition: pbx_app.c:463
const char * method
Definition: res_pjsip.c:1279
Generic container type.
struct ari_ws_session::@424 message_queue
struct ao2_container * websocket_apps
struct ast_websocket * ast_ws_session
int(* validator)(struct ast_json *)
Abstract JSON element (object, array, string, int, ...).
describes a server instance
Definition: tcptls.h:151
Structure for variables, used for configurations and for channel variables.
Structure definition for session.
Vector container support.
#define AST_VECTOR(name, type)
Define a vector structure.
Definition: vector.h:44