|
Asterisk - The Open Source Telephony Project
18.5.0
|
WebSocket support for RESTful API's. More...
#include "asterisk.h"#include "asterisk/ari.h"#include "asterisk/astobj2.h"#include "asterisk/http_websocket.h"#include "asterisk/stasis_app.h"#include "internal.h"
Go to the source code of this file.
Data Structures | |
| struct | ast_ari_websocket_session |
Macros | |
| #define | VALIDATION_FAILED |
Functions | |
| 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. More... | |
| 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. More... | |
| struct ast_sockaddr * | ast_ari_websocket_session_get_remote_addr (struct ast_ari_websocket_session *session) |
| Get the remote address from an ARI WebSocket. More... | |
| const char * | ast_ari_websocket_session_id (const struct ast_ari_websocket_session *session) |
| Get the Session ID for an ARI WebSocket. More... | |
| struct ast_json * | ast_ari_websocket_session_read (struct ast_ari_websocket_session *session) |
| Read a message from an ARI WebSocket. More... | |
| int | ast_ari_websocket_session_write (struct ast_ari_websocket_session *session, struct ast_json *message) |
| Send a message to an ARI WebSocket. More... | |
| static int | null_validator (struct ast_json *json) |
| Validator that always succeeds. More... | |
| static void | websocket_session_dtor (void *obj) |
WebSocket support for RESTful API's.
Definition in file ari_websockets.c.
| #define VALIDATION_FAILED |
Definition at line 152 of file ari_websockets.c.
Referenced by ast_ari_websocket_session_write().
| 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.
| ws_server | WebSocket server to invoke. |
| ser | HTTP session. |
| uri | Requested URI. |
| method | Requested HTTP method. |
| get_params | Parsed query parameters. |
| headers | Parsed HTTP headers. |
Definition at line 191 of file ari_websockets.c.
References ast_websocket_uri_cb(), and ast_http_uri::data.
Referenced by ast_ari_invoke().
| struct ast_ari_websocket_session* ast_ari_websocket_session_create | ( | struct ast_websocket * | ws_session, |
| int(*)(struct ast_json *) | validator | ||
| ) |
Create an ARI WebSocket session.
If NULL is given for the validator function, no validation will be performed.
| ws_session | Underlying WebSocket session. |
| validator | Function to validate outgoing messages. |
NULL on error. Definition at line 54 of file ari_websockets.c.
References ao2_alloc, ao2_cleanup, ao2_ref, ast_ari_config_get(), ast_log, ast_websocket_set_nonblock(), ast_websocket_set_timeout(), config, errno, LOG_ERROR, LOG_WARNING, NULL, null_validator(), RAII_VAR, session, ast_ari_websocket_session::validator, websocket_session_dtor(), and ast_ari_websocket_session::ws_session.
Referenced by ast_ari_events_event_websocket_ws_established_cb().
| struct ast_sockaddr* ast_ari_websocket_session_get_remote_addr | ( | struct ast_ari_websocket_session * | session | ) |
Get the remote address from an ARI WebSocket.
| session | Session to write to. |
Definition at line 185 of file ari_websockets.c.
References ast_websocket_remote_address(), and ast_ari_websocket_session::ws_session.
Referenced by ast_ari_websocket_session_write(), and stasis_app_message_handler().
| const char* ast_ari_websocket_session_id | ( | const struct ast_ari_websocket_session * | session | ) |
Get the Session ID for an ARI WebSocket.
| session | Session to query. |
NULL on error. Definition at line 203 of file ari_websockets.c.
References ast_websocket_session_id(), and ast_ari_websocket_session::ws_session.
Referenced by ast_ari_websocket_events_event_websocket_established().
| struct ast_json* ast_ari_websocket_session_read | ( | struct ast_ari_websocket_session * | session | ) |
Read a message from an ARI WebSocket.
| session | Session to read from. |
NULL if WebSocket could not be read. Definition at line 97 of file ari_websockets.c.
References ast_debug, ast_json_load_buf(), ast_json_ref(), ast_json_unref(), ast_log, ast_wait_for_input(), ast_websocket_fd(), AST_WEBSOCKET_OPCODE_CLOSE, AST_WEBSOCKET_OPCODE_TEXT, ast_websocket_read(), errno, LOG_WARNING, NULL, RAII_VAR, and ast_ari_websocket_session::ws_session.
Referenced by ast_ari_websocket_events_event_websocket_established().
| int ast_ari_websocket_session_write | ( | struct ast_ari_websocket_session * | session, |
| struct ast_json * | message | ||
| ) |
Send a message to an ARI WebSocket.
| session | Session to write to. |
| message | Message to send. |
Definition at line 158 of file ari_websockets.c.
References ast_ari_json_format(), ast_ari_websocket_session_get_remote_addr(), ast_json_dump_string_format(), ast_json_free(), ast_log, ast_sockaddr_stringify(), ast_websocket_write_string(), LOG_ERROR, LOG_NOTICE, NULL, RAII_VAR, str, VALIDATION_FAILED, ast_ari_websocket_session::validator, and ast_ari_websocket_session::ws_session.
Referenced by event_session_update_websocket(), and stasis_app_message_handler().
|
static |
Validator that always succeeds.
Definition at line 49 of file ari_websockets.c.
Referenced by ast_ari_websocket_session_create().
|
static |
Definition at line 38 of file ari_websockets.c.
References ast_websocket_unref(), NULL, session, and ast_ari_websocket_session::ws_session.
Referenced by ast_ari_websocket_session_create().
1.8.13