[svn-commits] dlee: branch dlee/stasis-http r382903 - in /team/dlee/stasis-http: apps/ res/...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Mar 12 14:14:29 CDT 2013
Author: dlee
Date: Tue Mar 12 14:14:26 2013
New Revision: 382903
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382903
Log:
Implemented hangup
Modified:
team/dlee/stasis-http/apps/app_stasis.c
team/dlee/stasis-http/res/stasis_http/resource_channels.c
Modified: team/dlee/stasis-http/apps/app_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/apps/app_stasis.c?view=diff&rev=382903&r1=382902&r2=382903
==============================================================================
--- team/dlee/stasis-http/apps/app_stasis.c (original)
+++ team/dlee/stasis-http/apps/app_stasis.c Tue Mar 12 14:14:26 2013
@@ -616,6 +616,7 @@
dispatch_commands(control, chan);
if (r == 0) {
+ /* Timeout */
continue;
}
Modified: team/dlee/stasis-http/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_channels.c?view=diff&rev=382903&r1=382902&r2=382903
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_channels.c (original)
+++ team/dlee/stasis-http/res/stasis_http/resource_channels.c Tue Mar 12 14:14:26 2013
@@ -83,9 +83,117 @@
const char *channel_id)
{
RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+
+ ast_assert(response != NULL);
+
+ control = stasis_app_control_find_by_channel_id(ast_channel_uniqueid(chan));
+ if (control == NULL) {
+ /* Distinguish between 404 and 409 errors */
+ RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
+ chan = ast_channel_get_by_name(channel_id);
+ if (chan == NULL) {
+ fill_error(response, 404, "Not Found",
+ "Channel not found");
+ return NULL;
+ }
+
+ fill_error(response, 409, "Conflict",
+ "Channel not in Stasis application");
+ return NULL;
+ }
+
+ ao2_ref(control, +1);
+ return control;
+}
+
+void stasis_http_dial(struct ast_variable *headers, struct ast_dial_args *args, struct stasis_http_response *response)
+{
+ ast_log(LOG_ERROR, "TODO: stasis_http_dial\n");
+}
+
+void stasis_http_continue_in_dialplan(struct ast_variable *headers, struct ast_continue_in_dialplan_args *args, struct stasis_http_response *response)
+{
+ RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+
+ ast_assert(response != NULL);
+
+ control = find_control(response, args->channel_id);
+ if (control == NULL) {
+ return;
+ }
+
+ stasis_app_control_continue(control);
+ fill_no_content(response);
+}
+
+void stasis_http_reject_channel(struct ast_variable *headers, struct ast_reject_channel_args *args, struct stasis_http_response *response)
+{
+ ast_log(LOG_ERROR, "TODO: stasis_http_reject_channel\n");
+}
+
+void stasis_http_answer_channel(struct ast_variable *headers,
+ struct ast_answer_channel_args *args,
+ struct stasis_http_response *response)
+{
+ RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+
+ control = find_control(response, args->channel_id);
+ if (control == NULL) {
+ return;
+ }
+
+ if (stasis_app_control_answer(control) != 0) {
+ fill_error(response, 500, "Internal Server Error",
+ "Failed to answer channel");
+ return;
+ }
+
+ fill_no_content(response);
+}
+
+void stasis_http_mute_channel(struct ast_variable *headers, struct ast_mute_channel_args *args, struct stasis_http_response *response)
+{
+ ast_log(LOG_ERROR, "TODO: stasis_http_mute_channel\n");
+}
+void stasis_http_unmute_channel(struct ast_variable *headers, struct ast_unmute_channel_args *args, struct stasis_http_response *response)
+{
+ ast_log(LOG_ERROR, "TODO: stasis_http_unmute_channel\n");
+}
+void stasis_http_record_channel(struct ast_variable *headers, struct ast_record_channel_args *args, struct stasis_http_response *response)
+{
+ ast_log(LOG_ERROR, "TODO: stasis_http_record_channel\n");
+}
+void stasis_http_get_channel(struct ast_variable *headers, struct ast_get_channel_args *args, struct stasis_http_response *response)
+{
+ RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+ struct ast_channel_snapshot *snapshot;
+
+ caching_topic = ast_channel_topic_all_cached();
+ if (!caching_topic) {
+ fill_error(response, 500, "Internal Server Error", "Message bus not initialized");
+ return;
+ }
+ ao2_ref(caching_topic, +1);
+
+ msg = stasis_cache_get(caching_topic, ast_channel_snapshot(), args->channel_id);
+ if (!msg) {
+ fill_error(response, 404, "Not Found", "Channel not found");
+ return;
+ }
+
+ snapshot = stasis_message_data(msg);
+ ast_assert(snapshot != NULL);
+
+ fill_ok(response, ast_channel_snapshot_to_json(snapshot));
+}
+
+void stasis_http_delete_channel(struct ast_variable *headers,
+ struct ast_delete_channel_args *args,
+ struct stasis_http_response *response)
+{
RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
-
- ast_assert(response != NULL);
+ int r;
chan = ast_channel_get_by_name(channel_id);
if (chan == NULL) {
@@ -94,103 +202,9 @@
return NULL;
}
- control = stasis_app_control_find_by_channel_id(ast_channel_uniqueid(chan));
- if (control == NULL) {
- /* Distinguish between 404 and 409 errors */
- fill_error(response, 409, "Conflict",
- "Channel not in Stasis application");
- return NULL;
- }
-
- ao2_ref(control, +1);
- return control;
-}
-
-void stasis_http_dial(struct ast_variable *headers, struct ast_dial_args *args, struct stasis_http_response *response)
-{
- ast_log(LOG_ERROR, "TODO: stasis_http_dial\n");
-}
-
-void stasis_http_continue_in_dialplan(struct ast_variable *headers, struct ast_continue_in_dialplan_args *args, struct stasis_http_response *response)
-{
- RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
-
- ast_assert(response != NULL);
-
- control = find_control(response, args->channel_id);
- if (control == NULL) {
- return;
- }
-
- stasis_app_control_continue(control);
+ ast_softhangup(chan, AST_SOFTHANGUP_EXPLICIT);
+
fill_no_content(response);
-}
-
-void stasis_http_reject_channel(struct ast_variable *headers, struct ast_reject_channel_args *args, struct stasis_http_response *response)
-{
- ast_log(LOG_ERROR, "TODO: stasis_http_reject_channel\n");
-}
-
-void stasis_http_answer_channel(struct ast_variable *headers,
- struct ast_answer_channel_args *args,
- struct stasis_http_response *response)
-{
- RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
-
- control = find_control(response, args->channel_id);
- if (control == NULL) {
- return;
- }
-
- if (stasis_app_control_answer(control) != 0) {
- fill_error(response, 500, "Internal Server Error",
- "Failed to answer channel");
- return;
- }
-
- fill_no_content(response);
-}
-
-void stasis_http_mute_channel(struct ast_variable *headers, struct ast_mute_channel_args *args, struct stasis_http_response *response)
-{
- ast_log(LOG_ERROR, "TODO: stasis_http_mute_channel\n");
-}
-void stasis_http_unmute_channel(struct ast_variable *headers, struct ast_unmute_channel_args *args, struct stasis_http_response *response)
-{
- ast_log(LOG_ERROR, "TODO: stasis_http_unmute_channel\n");
-}
-void stasis_http_record_channel(struct ast_variable *headers, struct ast_record_channel_args *args, struct stasis_http_response *response)
-{
- ast_log(LOG_ERROR, "TODO: stasis_http_record_channel\n");
-}
-void stasis_http_get_channel(struct ast_variable *headers, struct ast_get_channel_args *args, struct stasis_http_response *response)
-{
- RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
- struct ast_channel_snapshot *snapshot;
-
- caching_topic = ast_channel_topic_all_cached();
- if (!caching_topic) {
- fill_error(response, 500, "Internal Server Error", "Message bus not initialized");
- return;
- }
- ao2_ref(caching_topic, +1);
-
- msg = stasis_cache_get(caching_topic, ast_channel_snapshot(), args->channel_id);
- if (!msg) {
- fill_error(response, 404, "Not Found", "Channel not found");
- return;
- }
-
- snapshot = stasis_message_data(msg);
- ast_assert(snapshot != NULL);
-
- fill_ok(response, ast_channel_snapshot_to_json(snapshot));
-}
-
-void stasis_http_delete_channel(struct ast_variable *headers, struct ast_delete_channel_args *args, struct stasis_http_response *response)
-{
- ast_log(LOG_ERROR, "TODO: stasis_http_delete_channel\n");
}
void stasis_http_get_channels(struct ast_variable *headers, struct ast_get_channels_args *args, struct stasis_http_response *response)
More information about the svn-commits
mailing list