int ast_ari_websocket_session_write(struct ast_ari_websocket_session *session, struct ast_json *message) { RAII_VAR(char *, str, NULL, ast_json_free); #ifdef AST_DEVMODE if (!session->validator(message)) { ast_log(LOG_ERROR, "Outgoing message failed validation\n"); return ast_websocket_write_string(session->ws_session, VALIDATION_FAILED); } #endif str = ast_json_dump_string_format(message, ast_ari_json_format()); if (str == NULL) { ast_log(LOG_ERROR, "Failed to encode JSON object\n"); return -1; } ast_debug(3, "Examining ARI event (length %zu): \n%s\n", strlen(str), str); if (ast_websocket_write_string(session->ws_session, str)) { ast_log(LOG_NOTICE, "Problem occurred during websocket write, websocket closed\n"); return -1; } return 0; }
static int transport_websocket_send(void *obj, const char *data) { return ast_websocket_write_string(obj, data); }