60 if (ws_session ==
NULL) {
74 "ARI web socket failed to set nonblock; closing: %s\n",
81 config->general->write_timeout);
109 uint64_t payload_len;
123 &payload_len, &opcode, &fragmented);
139 "WebSocket input failed to parse\n");
152 #define VALIDATION_FAILED \ 154 " \"error\": \"InvalidMessage\"," \ 155 " \"message\": \"Message validation failed\"" \ 178 ast_log(
LOG_NOTICE,
"Problem occurred during websocket write to %s, websocket closed\n",
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)
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Asterisk main include file. File version handling, generic pbx functions.
enum ast_json_encoding_format ast_ari_json_format(void)
Configured encoding format for JSON output.
struct ast_json * ast_ari_websocket_session_read(struct ast_ari_websocket_session *session)
Read a message from an ARI WebSocket.
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.
struct ast_ari_conf * ast_ari_config_get(void)
Get the current ARI configuration.
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)
Wrapper for invoking the websocket code for an incoming connection.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
const char * ast_ari_websocket_session_id(const struct ast_ari_websocket_session *session)
Get the Session ID for an ARI WebSocket.
int(* validator)(struct ast_json *)
Structure for a WebSocket server.
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
All configuration options for ARI.
int ast_ari_websocket_session_write(struct ast_ari_websocket_session *session, struct ast_json *message)
Send a message to an ARI WebSocket.
Structure for variables, used for configurations and for channel variables.
struct ast_sockaddr * ast_ari_websocket_session_get_remote_addr(struct ast_ari_websocket_session *session)
Get the remote address from an ARI WebSocket.
Asterisk RESTful API hooks.
int AST_OPTIONAL_API_NAME() ast_websocket_write_string(struct ast_websocket *ws, const char *buf)
Socket address structure.
int AST_OPTIONAL_API_NAME() ast_websocket_fd(struct ast_websocket *session)
#define ast_debug(level,...)
Log a DEBUG message.
const char *AST_OPTIONAL_API_NAME() ast_websocket_session_id(struct ast_websocket *session)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
static int null_validator(struct ast_json *json)
Validator that always succeeds.
static struct ast_mansession session
#define VALIDATION_FAILED
#define ao2_ref(o, delta)
struct ast_sockaddr *AST_OPTIONAL_API_NAME() ast_websocket_remote_address(struct ast_websocket *session)
struct ast_websocket * ws_session
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to...
char * ast_json_dump_string_format(struct ast_json *root, enum ast_json_encoding_format format)
Encode a JSON value to a string.
describes a server instance
Internal API's for res_ari.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define ao2_alloc(data_size, destructor_fn)
int AST_OPTIONAL_API_NAME() ast_websocket_set_timeout(struct ast_websocket *session, int timeout)
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)
Structure definition for session.
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.
static void websocket_session_dtor(void *obj)
Definition of a URI handler.
Abstract JSON element (object, array, string, int, ...).
int ast_wait_for_input(int fd, int ms)
Stasis Application API. See Stasis Application API for detailed documentation.
ast_http_method
HTTP Request methods known by Asterisk.
int AST_OPTIONAL_API_NAME() ast_websocket_set_nonblock(struct ast_websocket *session)
void AST_OPTIONAL_API_NAME() ast_websocket_unref(struct ast_websocket *session)
ast_websocket_opcode
WebSocket operation codes.