[asterisk-commits] dlee: branch dlee/stasis-app r383607 - in /team/dlee/stasis-app: apps/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Mar 22 13:59:38 CDT 2013
Author: dlee
Date: Fri Mar 22 13:59:36 2013
New Revision: 383607
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383607
Log:
Resolved naming conflict of having two stasis_app types
Modified:
team/dlee/stasis-app/apps/app_stasis.c
team/dlee/stasis-app/res/res_stasis_websocket.c
Modified: team/dlee/stasis-app/apps/app_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-app/apps/app_stasis.c?view=diff&rev=383607&r1=383606&r2=383607
==============================================================================
--- team/dlee/stasis-app/apps/app_stasis.c (original)
+++ team/dlee/stasis-app/apps/app_stasis.c Fri Mar 22 13:59:36 2013
@@ -97,7 +97,7 @@
return __app_controls;
}
-struct stasis_app {
+struct app {
/*! Callback function for this application. */
stasis_app_cb handler;
/*! Opaque data to hand to callback function. */
@@ -106,10 +106,10 @@
char name[];
};
-/*! Constructor for \ref stasis_app. */
-static struct stasis_app *app_create(const char *name, stasis_app_cb handler, void *data)
-{
- struct stasis_app *app;
+/*! Constructor for \ref app. */
+static struct app *app_create(const char *name, stasis_app_cb handler, void *data)
+{
+ struct app *app;
size_t size;
ast_assert(name != NULL);
@@ -132,7 +132,7 @@
/*! AO2 hash function for \ref stasis_app */
static int app_hash(const void *obj, const int flags)
{
- const struct stasis_app *app = obj;
+ const struct app *app = obj;
const char *name = flags & OBJ_KEY ? obj : app->name;
return ast_str_hash(name);
@@ -141,8 +141,8 @@
/*! AO2 comparison function for \ref stasis_app */
static int app_compare(void *lhs, void *rhs, int flags)
{
- const struct stasis_app *lhs_app = lhs;
- const struct stasis_app *rhs_app = rhs;
+ const struct app *lhs_app = lhs;
+ const struct app *rhs_app = rhs;
const char *rhs_name = flags & OBJ_KEY ? rhs : rhs_app->name;
if (strcmp(lhs_app->name, rhs_name) == 0) {
@@ -157,7 +157,7 @@
* \param app App to send the message to.
* \param message Message to send.
*/
-static void app_send(struct stasis_app *app, struct ast_json *message)
+static void app_send(struct app *app, struct ast_json *message)
{
app->handler(app->data, app->name, message);
}
@@ -257,7 +257,7 @@
return ast_json_ref(message);
}
-static int send_start_msg(struct stasis_app *app, struct ast_channel *chan, int argc, char *argv[])
+static int send_start_msg(struct app *app, struct ast_channel *chan, int argc, char *argv[])
{
RAII_VAR(struct ast_json *, msg_info, NULL, ast_json_unref);
RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
@@ -299,7 +299,7 @@
return 0;
}
-static int send_end_msg(struct stasis_app *app, struct ast_channel *chan)
+static int send_end_msg(struct app *app, struct ast_channel *chan)
{
RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
@@ -322,7 +322,7 @@
static void sub_handler(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message)
{
- struct stasis_app *app = data;
+ struct app *app = data;
if (ast_channel_snapshot() == stasis_message_type(message)) {
RAII_VAR(struct ast_json *, msg, NULL, ast_json_unref);
struct ast_channel_snapshot *snapshot = stasis_message_data(message);
@@ -359,7 +359,7 @@
static int app_stasis_exec(struct ast_channel *chan, const char *data)
{
RAII_VAR(struct ao2_container *, apps, apps_registry(), ao2_cleanup);
- RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
+ RAII_VAR(struct app *, app, NULL, ao2_cleanup);
RAII_VAR(struct stasis_app_control *, control, NULL, control_unlink);
RAII_VAR(struct stasis_subscription *, subscription, NULL, stasis_unsubscribe);
int res = 0;
@@ -446,7 +446,7 @@
int stasis_app_send(const char *app_name, struct ast_json *message)
{
RAII_VAR(struct ao2_container *, apps, apps_registry(), ao2_cleanup);
- RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
+ RAII_VAR(struct app *, app, NULL, ao2_cleanup);
app = ao2_find(apps, app_name, OBJ_KEY);
@@ -465,7 +465,7 @@
int stasis_app_register(const char *app_name, stasis_app_cb handler, void *data)
{
RAII_VAR(struct ao2_container *, apps, apps_registry(), ao2_cleanup);
- RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
+ RAII_VAR(struct app *, app, NULL, ao2_cleanup);
SCOPED_LOCK(apps_lock, apps, ao2_lock, ao2_unlock);
Modified: team/dlee/stasis-app/res/res_stasis_websocket.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-app/res/res_stasis_websocket.c?view=diff&rev=383607&r1=383606&r2=383607
==============================================================================
--- team/dlee/stasis-app/res/res_stasis_websocket.c (original)
+++ team/dlee/stasis-app/res/res_stasis_websocket.c Fri Mar 22 13:59:36 2013
@@ -47,7 +47,7 @@
/*! Number of buckets for the Stasis application hash table. Remember to keep it a prime number! */
#define APPS_NUM_BUCKETS 7
-struct stasis_app {
+struct websocket_app {
char *name;
};
@@ -102,20 +102,20 @@
return ast_websocket_write(session, AST_WEBSOCKET_OPCODE_TEXT, str, strlen(str));
}
-/*! Hash function for stasis_app */
+/*! Hash function for websocket_app */
static int hash_app(const void *obj, const int flags)
{
- const struct stasis_app *app = obj;
+ const struct websocket_app *app = obj;
const char *name = flags & OBJ_KEY ? obj : app->name;
return ast_str_hash(name);
}
-/*! Comparison function for stasis_app */
+/*! Comparison function for websocket_app */
static int compare_app(void *lhs, void *rhs, int flags)
{
- const struct stasis_app *lhs_app = lhs;
- const struct stasis_app *rhs_app = rhs;
+ const struct websocket_app *lhs_app = lhs;
+ const struct websocket_app *rhs_app = rhs;
const char *rhs_name = flags & OBJ_KEY ? rhs : rhs_app->name;
if (strcmp(lhs_app->name, rhs_name) == 0) {
@@ -127,13 +127,13 @@
static void app_dtor(void *obj)
{
- struct stasis_app *app = obj;
+ struct websocket_app *app = obj;
ast_free(app->name);
}
struct stasis_ws_session_info {
struct ast_websocket *ws_session;
- struct ao2_container *stasis_apps;
+ struct ao2_container *websocket_apps;
};
static void app_handler(void *data, const char *app_name, struct ast_json *message)
@@ -169,34 +169,34 @@
if (strcmp("ActivateApplication", command) == 0) {
const char *app_name = ast_json_string_get(ast_json_object_get(req, "name"));
- RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
+ RAII_VAR(struct websocket_app *, app, NULL, ao2_cleanup);
if (ast_strlen_zero(app_name)) {
return build_err(id, "Missing application name");
}
- app = ao2_find(session->stasis_apps, app_name, OBJ_KEY);
+ app = ao2_find(session->websocket_apps, app_name, OBJ_KEY);
if (app) {
return build_err(id, "Application '%s' already registered", app_name);
}
app = ao2_alloc(sizeof(*app), app_dtor);
if (!app) {
- ast_log(LOG_ERROR, "Failed to construct stasis_app");
+ ast_log(LOG_ERROR, "Failed to construct websocket_app");
return build_err(id, "Internal error");
}
app->name = ast_strdup(app_name);
- ao2_link(session->stasis_apps, app);
+ ao2_link(session->websocket_apps, app);
stasis_app_register(app_name, app_handler, session);
return build_success(id, "Application activated");
} else if (strcmp("DeactivateApplication", command) == 0) {
const char *app_name = ast_json_string_get(ast_json_object_get(req, "name"));
- RAII_VAR(struct stasis_app *, app, NULL, ao2_cleanup);
+ RAII_VAR(struct websocket_app *, app, NULL, ao2_cleanup);
if (ast_strlen_zero(app_name)) {
return build_err(id, "Missing application name");
}
- app = ao2_find(session->stasis_apps, app_name, OBJ_KEY | OBJ_UNLINK);
+ app = ao2_find(session->websocket_apps, app_name, OBJ_KEY | OBJ_UNLINK);
if (app == NULL) {
return build_err(id, "Application '%s' not activated", app_name);
}
@@ -213,7 +213,7 @@
{
struct stasis_ws_session_info stasis_session = {};
struct ao2_iterator i;
- struct stasis_app *app;
+ struct websocket_app *app;
int res;
ast_debug(3, "Stasis web socket connection\n");
@@ -223,7 +223,7 @@
goto end;
}
- stasis_session.stasis_apps = ao2_container_alloc(APPS_NUM_BUCKETS, hash_app, compare_app);
+ stasis_session.websocket_apps = ao2_container_alloc(APPS_NUM_BUCKETS, hash_app, compare_app);
stasis_session.ws_session = session;
while ((res = ast_wait_for_input(ast_websocket_fd(session), -1)) > 0) {
@@ -266,13 +266,13 @@
}
end:
- i = ao2_iterator_init(stasis_session.stasis_apps, 0);
+ i = ao2_iterator_init(stasis_session.websocket_apps, 0);
while ((app = ao2_iterator_next(&i))) {
stasis_app_unregister(app->name);
ao2_cleanup(app);
}
ao2_iterator_destroy(&i);
- ao2_cleanup(stasis_session.stasis_apps);
+ ao2_cleanup(stasis_session.websocket_apps);
ast_websocket_unref(session);
}
More information about the asterisk-commits
mailing list