45#define SESSION_REGISTRY_NUM_BUCKETS 23 
   48#define APPS_INIT_SIZE 7 
   51#define MESSAGES_INIT_SIZE 23 
   53#define ARI_CONTEXT_REGISTRAR "res_ari" 
   60#if defined(AST_DEVMODE) 
   75#define VALIDATION_FAILED               \ 
   77    "  \"error\": \"InvalidMessage\","      \ 
   78    "  \"message\": \"Message validation failed\""  \ 
 
  104        ast_log(
LOG_NOTICE, 
"Problem occurred during websocket write to %s, websocket closed\n",
 
 
  122                "%s: Failed to dispatch '%s' message from Stasis app '%s'; could not update message\n",
 
  137                "%s: Failed to dispatch '%s' message from Stasis app '%s'; could not update message\n",
 
  142    if (!
session->ast_ws_session) {
 
  153                    "%s: Queued '%s' message for Stasis app '%s'; websocket is not ready\n",
 
  163            ast_verbose(
"<--- Sending ARI event to %s --->\n%s\n",
 
 
  173    const char *event_type, 
const char *
app_name)
 
 
  211        uint64_t payload_len;
 
  225            &payload_len, &opcode, &fragmented);
 
  241                    "{s:s, s:s, s:s, s:i, s:s, s:s }",
 
  242                    "type", 
"RESTResponse",
 
  243                    "transaction_id", 
"",
 
  246                    "reason_phrase", 
"Failed to parse request message JSON",
 
  253                    "WebSocket input failed to parse\n");
 
 
  295    const char *msg_type, *msg_application;
 
  303    msg_application = 
S_OR(
 
  309        && strcmp(msg_type, 
"ApplicationReplaced") == 0 &&
 
  310        strcmp(msg_application, 
app_name) == 0) {
 
  319            "%s: Failed to dispatch '%s' message from Stasis app '%s'; could not update message\n",
 
  320            remote_addr, msg_type, msg_application);
 
  336            ast_debug(3, 
"%s: StasisEnd message sent for channel '%s'\n",
 
  342    SCOPE_EXIT(
"%s: Dispatched '%s' message from Stasis app '%s'\n",
 
 
  353        ast_debug(3, 
"Stasis app '%s' message handler called with NULL session.  OK for per_call_config websocket.\n",
 
 
  372    ast_debug(3, 
"%s: Trying to unregister app '%s'\n",
 
  377        ast_debug(3, 
"%s: Unregistering context '%s' for app '%s'\n",
 
  381        ast_debug(3, 
"%s: Unregistering stasis app '%s' and unsubscribing from all events.\n",
 
 
  401    if (app_count == 0) {
 
 
  420    ast_debug(3, 
"%s: Registering apps '%s'.  Subscribe all: %s\n",
 
  488            if (!already_registered
 
  502        if (app_counter == 1) {
 
 
  536    ast_debug(3, 
"%s: Resetting ARI websocket session\n",
 
 
  561    ast_debug(3, 
"%s: Cleaning up ARI websocket session RC: %d\n",
 
  567        ast_debug(3, 
"%s: Unlinking websocket session from registry RC: %d\n",
 
 
  592    ast_debug(3, 
"%s: Destroying ARI websocket session\n",
 
  601    if (!
session->ast_ws_session) {
 
 
  608#define handle_create_error(ser, code, msg, reason) \ 
  611        ast_http_error(ser, code, msg, reason); \ 
  613    ast_log(LOG_WARNING, "Failed to create ARI websocket session: %d %s %s\n", \ 
  614        code, msg, reason); \ 
 
  628    ast_debug(3, 
"%s: Creating ARI websocket session for apps '%s'\n",
 
  631    size = 
sizeof(*session) + strlen(
session_id) + 1;
 
  646            "Allocation failed");
 
  653            "Allocation failed");
 
  666            "Stasis app registration failed");
 
  673            "Allocation failed");
 
 
  715            "ARI web socket failed to set nonblock; closing: %s\n",
 
  722            general->write_timeout);
 
  737    if (send_registered_events) {
 
  744                "ApplicationRegistered", 
app);
 
 
  762    const char *session_id)
 
  771            "HTTP request is missing param: [app]");
 
  781            "Failed to create ARI websocket session");
 
 
  811    SCOPE_ENTER(2, 
"%s: WebSocket established\n", remote_addr);
 
  814        ast_trace(2, 
"%s: Websocket Upgrade Headers:\n", remote_addr);
 
  815        for (v = upgrade_headers; v; v = v->
next) {
 
  827            "%s: Failed to locate an event session for the websocket session %s\n",
 
  828            remote_addr, session_id);
 
  839    ast_trace(-1, 
"%s: Waiting for messages\n", remote_addr);
 
  847    SCOPE_EXIT(
"%s: Websocket closed\n", remote_addr);
 
 
  893    unsigned int ws_type)
 
  905        if (!(
session->type & ws_type)) {
 
 
  932    int already_sent_registers = 1;
 
  934    ast_debug(3, 
"%s: Starting outbound websocket thread RC: %d\n",
 
  936    session->thread = pthread_self();
 
  946            session->owc->websocket_client->uri);
 
  955                    ast_debug(3, 
"%s: Connection failed.  Returning to dialplan.\n",
 
  961                    ast_debug(3, 
"%s: Connection failed.  No control object found.\n",
 
  967            usleep(
session->owc->websocket_client->reconnect_interval * 1000);
 
  972                session->owc->websocket_client->uri);
 
  980        already_sent_registers = 0;
 
  992        if (!upgrade_headers) {
 
 1001        ast_debug(3, 
"%s: Waiting for messages RC: %d\n",
 
 1010                upgrade_headers, 
session->app_name, msg);
 
 1018            ast_debug(3, 
"%s: Websocket closing RC: %d\n",
 
 1027    ast_debug(3, 
"%s: Stopping outbound websocket thread RC: %d\n",
 
 
 1052        ast_debug(2, 
"%s: No changes detected\n", new_owc_id);
 
 1055    ast_debug(2, 
"%s: Config change detected.  Checking details\n", new_owc_id);
 
 1058        ast_debug(2, 
"%s: Re-registering apps\n", new_owc_id);
 
 1082                    ast_debug(3, 
"%s: Unlinked app '%s' to keep it from being unregistered\n",
 
 1102                new_owc_id, new_owc->
apps);
 
 1107                        session->owc->subscribe_all) < 0) {
 
 1109                    new_owc_id, 
session->owc->apps);
 
 1126        ast_debug(2, 
"%s: Reconnect required\n", new_owc_id);
 
 1128        if (
session->ast_ws_session) {
 
 1129            ast_debug(2, 
"%s: Closing websocket\n", new_owc_id);
 
 1134    return apply_result;
 
 
 1146#define PER_CALL_FAIL_SAFE_TIMEOUT(owc) \ 
 1147    (int64_t)((owc->websocket_client->connect_timeout + owc->websocket_client->reconnect_interval) \ 
 1148    * (owc->websocket_client->reconnect_attempts + 3)) 
 
 1165    const char *owc_id = 
NULL;
 
 1166    char *app_id_rtn = 
NULL;
 
 1167    struct timeval tv_start;
 
 1172        ast_log(
LOG_WARNING, 
"%s: Failed to find outbound websocket per-call config for app '%s'\n",
 
 1179    if (invalid_fields) {
 
 1180        ast_log(
LOG_WARNING, 
"%s: Unable to create per-call websocket.  Outbound websocket config is invalid\n",
 
 1246    ast_debug(3, 
"%s: Created per call websocket for app '%s'\n",
 
 1247        session_id, app_id);
 
 1252    app_id_rtn = app_id;
 
 
 1257#define STASIS_END_MAX_WAIT_MS 5000 
 1258#define STASIS_END_POST_WAIT_US (3000 * 1000) 
 1278    ast_debug(3, 
"%s: Waiting for %dms before closing websocket RC: %d\n",
 
 1283    if (
session->ast_ws_session) {
 
 
 1299    struct timeval tv_start;
 
 1320    ast_debug(3, 
"%s: Waiting for StasisEnd event to be sent RC: %d\n",
 
 1327        ast_debug(3, 
"%s: Waiting for StasisEnd event %lu %d %ld\n",
 
 1329            session->stasis_end_sent, diff);
 
 1336    ast_debug(3, 
"%s: StasisEnd event sent.  Scheduling websocket close. RC: %d\n",
 
 1354    ast_debug(3, 
"%s: Scheduled websocket close RC: %d\n",
 
 
 1375        ast_debug(2, 
"%s: Found existing connection\n", owc_id);
 
 1376        if (invalid_fields) {
 
 1379                "%s: Unable to update websocket session. Outbound websocket config is invalid\n",
 
 1390                "%s: Failed to apply new configuration. Existing connection preserved.\n",
 
 1396    if (invalid_fields) {
 
 1398            "%s: Unable to create websocket session. Outbound websocket config is invalid\n",
 
 
 1436    ast_debug(2, 
"Reloading ARI websockets\n");
 
 1449                ast_debug(3, 
"Cleaning up outbound websocket %s\n",
 
 1453                if (
session->ast_ws_session) {
 
 
 1537        ari_ws_session_sort_fn, ari_ws_session_cmp_fn);
 
 1540                "Failed to allocate the local registry for websocket applications\n");
 
 
Asterisk RESTful API hooks.
enum ast_json_encoding_format ast_ari_json_format(void)
Configured encoding format for JSON output.
int ast_ari_validate_message(struct ast_json *json)
Validator for Message.
Generated file - Build validators for ARI model objects.
int(* ari_validator)(struct ast_json *json)
Function type for validator functions. Allows for.
int ari_websocket_process_request(struct ari_ws_session *ari_ws_session, const char *remote_addr, struct ast_variable *upgrade_headers, const char *app_name, struct ast_json *request_msg)
static struct ast_sorcery_observer observer_callbacks
static struct ari_ws_session * session_find_by_app(const char *app_name, unsigned int ws_type)
int ari_outbound_websocket_start(struct ari_conf_outbound_websocket *owc)
static int null_validator(struct ast_json *json)
Validator that always succeeds.
static void session_reset(struct ari_ws_session *session)
static void session_send_or_queue(struct ari_ws_session *session, struct ast_json *message, const char *msg_type, const char *app_name, int debug_app)
static struct ari_ws_session * session_create(struct ast_tcptls_session_instance *ser, const char *apps, int subscribe_all, const char *session_id, struct ari_conf_outbound_websocket *ows, enum ast_websocket_type ws_type)
static void session_dtor(void *obj)
static void stasis_app_message_handler(void *data, const char *app_name, struct ast_json *message)
#define STASIS_END_POST_WAIT_US
static void * outbound_session_handler_thread(void *obj)
struct ari_ws_session * ari_websocket_get_session(const char *session_id)
static int websocket_attempted_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *headers, const char *session_id)
static void outbound_sessions_load(const char *name)
static int outbound_session_create(void *obj, void *args, int flags)
void ari_websocket_shutdown_all(void)
@ SESSION_APPLY_RECONNECT_REQUIRED
@ SESSION_APPLY_NO_CHANGE
#define MESSAGES_INIT_SIZE
static struct ao2_container * session_registry
Local registry for created ari_ws_session objects.
void ari_websocket_send_event(struct ari_ws_session *session, const char *app_name, struct ast_json *message, int debug_app)
Callback handler for Stasis application messages.
static void session_unregister_apps(struct ari_ws_session *session)
int ari_websocket_load_module(int is_enabled)
static void session_unref(struct ari_ws_session *session)
#define STASIS_END_MAX_WAIT_MS
static void * outbound_session_pc_close_thread(void *data)
static void session_cleanup(struct ari_ws_session *session)
void ast_ari_close_per_call_websocket(char *app_name)
This function is called by the app_stasis dialplan app to close a per-call websocket after stasis_app...
char * ast_ari_create_per_call_websocket(const char *app_name, struct ast_channel *chan)
This function gets called by app_stasis when a call arrives but a Stasis application isn't already re...
#define PER_CALL_FAIL_SAFE_TIMEOUT(owc)
static void session_unregister_app_cb(char *app_name, struct ari_ws_session *session)
static void session_send_app_event(struct ari_ws_session *session, const char *event_type, const char *app_name)
static int session_write(struct ari_ws_session *session, struct ast_json *message)
ari_validator ari_validate_message_fn
static void websocket_established_cb(struct ast_websocket *ast_ws_session, struct ast_variable *get_params, struct ast_variable *upgrade_headers)
void ari_websocket_shutdown(struct ari_ws_session *session)
#define ARI_CONTEXT_REGISTRAR
static int session_shutdown_cb(void *obj, void *arg, int flags)
struct ast_websocket_server * ast_ws_server
static int session_register_apps(struct ari_ws_session *session, const char *_apps, int subscribe_all)
static enum session_apply_result outbound_session_apply_config(struct ari_ws_session *session, struct ari_conf_outbound_websocket *new_owc)
int ari_websocket_unload_module(void)
#define handle_create_error(ser, code, msg, reason)
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.
#define VALIDATION_FAILED
struct ao2_container * ari_websocket_get_sessions(void)
static void session_registry_dtor(void)
static struct ast_json * session_read(struct ari_ws_session *session)
static int session_update(struct ari_ws_session *ari_ws_session, struct ast_websocket *ast_ws_session, int send_registered_events)
Internal API's for websockets.
#define STASIS_CONTEXT_PREFIX
#define ARI_MAX_APP_NAME_LEN
const char * ari_websocket_type_to_str(enum ast_websocket_type type)
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_strdupa(s)
duplicate a string in memory from the stack
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ao2_iterator_next(iter)
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define AO2_STRING_FIELD_CMP_FN(stype, field)
Creates a compare function for a structure string field.
#define ao2_unlink(container, obj)
Remove an object from a container.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define AO2_STRING_FIELD_SORT_FN(stype, field)
Creates a sort function for a structure string field.
#define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a red-black tree container.
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
#define ao2_alloc(data_size, destructor_fn)
@ AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE
Replace objects with duplicate keys in container.
const char * ast_channel_name(const struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
static const char context_name[]
#define TRACE_ATLEAST(level)
#define SCOPE_ENTER(level,...)
#define SCOPE_EXIT_LOG_RTN(__log_level,...)
#define ast_trace(level,...)
ast_http_method
HTTP Request methods known by Asterisk.
struct ast_variable * ast_http_create_basic_auth_header(const char *userid, const char *password)
Create an HTTP authorization header.
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to...
const char *AST_OPTIONAL_API_NAME() ast_websocket_session_id(struct ast_websocket *session)
Get the session ID for a WebSocket session.
int AST_OPTIONAL_API_NAME() ast_websocket_server_add_protocol2(struct ast_websocket_server *server, struct ast_websocket_protocol *protocol)
Add a sub-protocol handler to the given server.
int AST_OPTIONAL_API_NAME() ast_websocket_write_string(struct ast_websocket *ws, const char *buf)
Construct and transmit a WebSocket frame containing string data.
struct ast_sockaddr *AST_OPTIONAL_API_NAME() ast_websocket_remote_address(struct ast_websocket *session)
Get the remote address for a WebSocket connected session.
int AST_OPTIONAL_API_NAME() ast_websocket_uri_cb(struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_vars, struct ast_variable *headers)
Callback suitable for use with a ast_http_uri.
ast_websocket_result
Result code for a websocket client.
int AST_OPTIONAL_API_NAME() ast_websocket_fd(struct ast_websocket *session)
Get the file descriptor for a WebSocket session.
ast_websocket_opcode
WebSocket operation codes.
@ AST_WEBSOCKET_OPCODE_CLOSE
@ AST_WEBSOCKET_OPCODE_TEXT
int AST_OPTIONAL_API_NAME() ast_websocket_set_nonblock(struct ast_websocket *session)
Set the socket of a WebSocket session to be non-blocking.
ast_websocket_type
WebSocket connection/configuration types.
@ AST_WS_TYPE_CLIENT_PER_CALL_CONFIG
@ AST_WS_TYPE_CLIENT_PERSISTENT
@ AST_WS_TYPE_CLIENT_PER_CALL
struct ast_websocket_protocol *AST_OPTIONAL_API_NAME() ast_websocket_sub_protocol_alloc(const char *name)
Allocate a websocket sub-protocol instance.
int AST_OPTIONAL_API_NAME() ast_websocket_set_timeout(struct ast_websocket *session, int timeout)
Set the timeout on a non-blocking WebSocket session.
int AST_OPTIONAL_API_NAME() ast_websocket_read(struct ast_websocket *session, char **payload, uint64_t *payload_len, enum ast_websocket_opcode *opcode, int *fragmented)
Read a WebSocket frame and handle it.
int AST_OPTIONAL_API_NAME() ast_websocket_close(struct ast_websocket *session, uint16_t reason)
Close a WebSocket session by sending a message with the CLOSE opcode and an optional code.
struct ast_websocket_server *AST_OPTIONAL_API_NAME() ast_websocket_server_create(void)
Creates a ast_websocket_server.
void AST_OPTIONAL_API_NAME() ast_websocket_unref(struct ast_websocket *session)
Decrease the reference count for a WebSocket session.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
const char * ast_variable_find_in_list(const struct ast_variable *list, const char *variable)
Gets the value of a variable from a variable list by name.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
#define DEBUG_ATLEAST(level)
#define ast_debug(level,...)
Log a DEBUG message.
Internal API's for res_ari.
@ ARI_OWC_NEEDS_REREGISTER
@ ARI_OWC_FIELD_SUBSCRIBE_ALL
@ ARI_OWC_NEEDS_RECONNECT
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
struct ast_json * ast_json_load_buf(const char *buffer, size_t buflen, struct ast_json_error *error)
Parse buffer with known length into a JSON object or array.
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.
char * ast_json_dump_string_format(struct ast_json *root, enum ast_json_encoding_format format)
Encode a JSON value to a string.
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
static int subscribe_all(void)
Asterisk module definitions.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
Core PBX routines and definitions.
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
struct ast_context * ast_context_find(const char *name)
Find a context.
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
const char * app_name(struct ast_app *app)
struct ari_conf_outbound_websocket * ari_conf_get_owc_for_app(const char *app_name, unsigned int ws_type)
Get the outbound websocket configuration for a Stasis app.
int ari_sorcery_observer_remove(const char *object_type, const struct ast_sorcery_observer *callbacks)
enum ari_conf_owc_fields ari_conf_owc_get_invalid_fields(const char *id)
struct ao2_container * ari_conf_get_owcs(void)
enum ari_conf_owc_fields ari_conf_owc_detect_changes(struct ari_conf_outbound_websocket *old_owc, struct ari_conf_outbound_websocket *new_owc)
Detect changes between two outbound websocket configurations.
int ari_sorcery_observer_add(const char *object_type, const struct ast_sorcery_observer *callbacks)
struct ari_conf_general * ari_conf_get_general(void)
struct ari_conf_outbound_websocket * ari_conf_get_owc(const char *id)
static int is_enabled(void)
Helper function to check if module is enabled.
static struct timeval msg_timestamp(void *msg, enum smdi_message_type type)
static void cleanup(void)
Clean up any old apps that we don't need any more.
Generated file - declares stubs to be implemented in res/ari/resource_events.c.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Stasis Application API. See Stasis Application API for detailed documentation.
void stasis_app_control_mark_failed(struct stasis_app_control *control)
Set the failed flag on a control structure.
int stasis_app_event_allowed(const char *app_name, struct ast_json *event)
Check if the given event should be filtered.
int stasis_app_is_registered(const char *name)
Check if a Stasis application is registered.
int stasis_app_control_continue(struct stasis_app_control *control, const char *context, const char *extension, int priority)
Exit res_stasis and continue execution in the dialplan.
int stasis_app_register(const char *app_name, stasis_app_cb handler, void *data)
Register a new Stasis application.
void stasis_app_unregister(const char *app_name)
Unregister a Stasis application and unsubscribe from all event sources.
struct stasis_app_control * stasis_app_control_find_by_channel_id(const char *channel_id)
Returns the handler for the channel with the given id.
int stasis_app_register_all(const char *app_name, stasis_app_cb handler, void *data)
Register a new Stasis application that receives all Asterisk events.
int stasis_app_get_debug_by_name(const char *app_name)
Get debug status of an application.
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int ast_in_delimited_string(const char *needle, const char *haystack, char delim)
Check if there is an exact match for 'needle' between delimiters in 'haystack'.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Registered applications container.
Global configuration options for ARI.
const ast_string_field apps
struct ast_websocket_client * websocket_client
struct ast_vector_string websocket_apps
struct ari_conf_outbound_websocket * owc
struct ari_ws_session::@456 message_queue
struct ast_websocket * ast_ws_session
Main Channel structure associated with a channel.
Definition of a URI handler.
Abstract JSON element (object, array, string, int, ...).
Interface for a sorcery object type observer.
void(* loaded)(const char *object_type)
Callback for when an object type is loaded/reloaded.
describes a server instance
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
enum ast_websocket_type connection_type
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 for a WebSocket server.
Structure definition for session.
Time-related functions and macros.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int error(const char *format,...)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_wait_for_input(int fd, int ms)
char * ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
Convert an EID to a string.
#define ast_pthread_create_detached_background(a, b, c, d)
struct ast_eid ast_eid_default
Global EID.
Universally unique identifier support.
Vector container support.
#define AST_VECTOR_REMOVE_ORDERED(vec, idx)
Remove an element from a vector by index while maintaining order.
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_REMOVE_CMP_ORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison while maintaining order.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_GET_CMP(vec, value, cmp)
Get an element from a vector that matches the given comparison.
#define AST_VECTOR_ADD_SORTED(vec, elem, cmp)
Add an element into a sorted vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
struct ast_websocket * ast_websocket_client_connect(struct ast_websocket_client *wc, void *lock_obj, const char *display_name, enum ast_websocket_result *result)
Connect to a websocket server using the configured authentication, retry and TLS options.