48#if defined(AST_DEVMODE)
69 for (i = get_params; i; i = i->
next) {
70 if (strcmp(i->
name,
"app") == 0) {
76 if (!
args.app_parse) {
81 if (strlen(
args.app_parse) == 0) {
84 vals[0] =
args.app_parse;
87 args.app_parse,
',', vals,
91 if (
args.app_count == 0) {
99 "Too many values for app");
109 for (j = 0; j <
args.app_count; ++j) {
110 args.app[j] = (vals[j]);
113 if (strcmp(i->
name,
"subscribeAll") == 0) {
121fin: __attribute__((unused))
123 ast_http_error(ser, 500,
"Server Error",
"Memory allocation error");
125 }
else if (response->response_code != 0) {
128 if (response->message) {
135 ast_http_error(ser, response->response_code, response->response_text, msg);
161#if defined(AST_DEVMODE)
172 for (i = get_params; i; i = i->
next) {
173 if (strcmp(i->
name,
"app") == 0) {
179 if (!
args.app_parse) {
184 if (strlen(
args.app_parse) == 0) {
187 vals[0] =
args.app_parse;
190 args.app_parse,
',', vals,
194 if (
args.app_count == 0) {
202 "Too many values for app");
212 for (j = 0; j <
args.app_count; ++j) {
213 args.app[j] = (vals[j]);
216 if (strcmp(i->
name,
"subscribeAll") == 0) {
224fin: __attribute__((unused))
225 if (response && response->response_code != 0) {
228 if (response->message) {
267 for (i = 0; i <
args->source_count; ++i) {
272 args->source_count = 1;
299#if defined(AST_DEVMODE)
304 for (i = get_params; i; i = i->
next) {
305 if (strcmp(i->
name,
"application") == 0) {
308 if (strcmp(i->
name,
"source") == 0) {
314 if (!
args.source_parse) {
319 if (strlen(
args.source_parse) == 0) {
321 args.source_count = 1;
322 vals[0] =
args.source_parse;
325 args.source_parse,
',', vals,
329 if (
args.source_count == 0) {
337 "Too many values for source");
347 for (j = 0; j <
args.source_count; ++j) {
348 args.source[j] = (vals[j]);
353 for (i = path_vars; i; i = i->
next) {
354 if (strcmp(i->
name,
"eventName") == 0) {
359 args.variables = body;
361#if defined(AST_DEVMODE)
376 if (200 <= code && code <= 299) {
380 ast_log(
LOG_ERROR,
"Invalid error response %d for /events/user/{eventName}\n", code);
386 ast_log(
LOG_ERROR,
"Response validation failed for /events/user/{eventName}\n");
388 "Internal Server Error",
"Response validation failed");
392fin: __attribute__((unused))
474 .
requires =
"res_ari,res_ari_model,res_stasis,res_http_websocket",
struct ast_ari_websocket_session * ast_ari_websocket_session_create(struct ast_websocket *ws_session, int(*validator)(struct ast_json *))
Create an ARI WebSocket session.
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
void ast_ari_response_error(struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...)
Fill in an error ast_ari_response.
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
ari_validator ast_ari_validate_message_fn(void)
Function pointer to ast_ari_validate_message().
Generated file - Build validators for ARI model objects.
int ast_ari_validate_void(struct ast_json *json)
Validator for native Swagger void.
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_strdup(str)
A wrapper for strdup()
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ast_http_error(struct ast_tcptls_session_instance *ser, int status, const char *title, const char *text)
Send HTTP error message and close socket.
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to...
struct ast_websocket_protocol * ast_websocket_sub_protocol_alloc(const char *name)
Allocate a websocket sub-protocol instance.
@ AST_WEBSOCKET_OPCODE_TEXT
void ast_websocket_unref(struct ast_websocket *session)
Decrease the reference count for a WebSocket session.
int ast_websocket_server_add_protocol2(struct ast_websocket_server *server, struct ast_websocket_protocol *protocol)
Add a sub-protocol handler to the given server.
struct ast_websocket_server * ast_websocket_server_create(void)
Creates a ast_websocket_server.
int ast_websocket_write(struct ast_websocket *session, enum ast_websocket_opcode opcode, char *payload, uint64_t payload_size)
Construct and transmit a WebSocket frame.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define ast_app_separate_args(a, b, c, d)
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
Asterisk module definitions.
#define SCOPED_MODULE_USE(module)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
int ast_ari_events_user_event_parse_body(struct ast_json *body, struct ast_ari_events_user_event_args *args)
Body parsing function for /events/user/{eventName}.
static void ast_ari_events_event_websocket_ws_established_cb(struct ast_websocket *ws_session, struct ast_variable *get_params, struct ast_variable *headers)
static struct stasis_rest_handlers events
REST handler for /api-docs/events.json.
static struct stasis_rest_handlers events_user_eventName
REST handler for /api-docs/events.json.
static int ast_ari_events_event_websocket_ws_attempted_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *headers, const char *session_id)
static struct stasis_rest_handlers events_user
REST handler for /api-docs/events.json.
static void ast_ari_events_user_event_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /events/user/{eventName}.
static int load_module(void)
static int unload_module(void)
void ast_ari_websocket_events_event_websocket_established(struct ast_ari_websocket_session *ws_session, struct ast_variable *headers, struct ast_ari_events_event_websocket_args *args)
WebSocket connection for events.
void ast_ari_events_user_event(struct ast_variable *headers, struct ast_ari_events_user_event_args *args, struct ast_ari_response *response)
Generate a user event.
int ast_ari_websocket_events_event_websocket_attempted(struct ast_tcptls_session_instance *ser, struct ast_variable *headers, struct ast_ari_events_event_websocket_args *args, const char *session_id)
WebSocket connection for events.
int ast_ari_websocket_events_event_websocket_init(void)
WebSocket connection for events.
void ast_ari_websocket_events_event_websocket_dtor(void)
WebSocket connection for events.
Generated file - declares stubs to be implemented in res/ari/resource_events.c.
Stasis Application API. See Stasis Application API for detailed documentation.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
struct ast_json * message
Abstract JSON element (object, array, string, int, ...).
describes a server instance
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
A websocket protocol implementation.
ast_websocket_callback session_established
Callback called when a new session is established. Mandatory.
ast_websocket_pre_callback session_attempted
Callback called when a new session is attempted. Optional.
Structure definition for session.
Handler for a single RESTful path segment.
const char * path_segment
struct ast_websocket_server * ws_server
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.