summaryrefslogtreecommitdiff
path: root/pbx
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-03-22 14:06:46 +0000
committerDavid M. Lee <dlee@digium.com>2013-03-22 14:06:46 +0000
commitcf9324b25eb8a7dc5cef77f54e12758dfbcd6645 (patch)
tree67492a4753d03498d3b842939d1c4c9256efa013 /pbx
parent401f7c188038a327ed40a7bff30a28f03b69f8a1 (diff)
Move more channel events to Stasis; move res_json.c to main/json.c.
This patch started out simply as fixing the bouncing tests introduced in r382685, but required some other changes to give it a decent implementation. To fix the bouncing tests, the UserEvent and Newexten AMI events needed to be refactored to dispatch via Stasis. Dispatching directly to AMI resulted in those events sometimes getting ahead of the associated Newchannel events, which would understandably confuse anyone. I found that instead of creating a zillion different message types and structures associated with them, it would be preferable to define a message type that has a channel snapshot and a blob of structured data with a small bit of additional information. The JSON object model provides a very nice way of representing structured data, so I went with that. * Move JSON support from res_json.c to main/json.c * Made libjansson-dev a required dependency * Added an ast_channel_blob message type, which has a channel snapshot and JSON blob of data. * Changed UserEvent and Newexten events so that they are dispatched via ast_channel_blob messages on the channel's topic. * Got rid of the ast_channel_varset message; used ast_channel_blob instead. * Extracted the manager functions converting Stasis channel events to AMI events into manager_channel.c. (issue ASTERISK-21096) Review: https://reviewboard.asterisk.org/r/2381/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383579 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx')
-rw-r--r--pbx/pbx_realtime.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c
index 3808483ad..d1cb5ed39 100644
--- a/pbx/pbx_realtime.c
+++ b/pbx/pbx_realtime.c
@@ -345,6 +345,8 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
char tmp1[80];
char tmp2[80];
char tmp3[EXT_DATA_SIZE];
+ RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+ RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
appdata[0] = 0; /* just in case the substitute var func isn't called */
if(!ast_strlen_zero(tmp))
@@ -354,16 +356,18 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
term_color(tmp1, app, COLOR_BRCYAN, 0, sizeof(tmp1)),
term_color(tmp2, ast_channel_name(chan), COLOR_BRMAGENTA, 0, sizeof(tmp2)),
term_color(tmp3, S_OR(appdata, ""), COLOR_BRMAGENTA, 0, sizeof(tmp3)));
- manager_event(EVENT_FLAG_DIALPLAN, "Newexten",
- "Channel: %s\r\n"
- "Context: %s\r\n"
- "Extension: %s\r\n"
- "Priority: %d\r\n"
- "Application: %s\r\n"
- "AppData: %s\r\n"
- "Uniqueid: %s\r\n",
- ast_channel_name(chan), ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), app, !ast_strlen_zero(appdata) ? appdata : "(NULL)", ast_channel_uniqueid(chan));
-
+ snapshot = ast_channel_snapshot_create(chan);
+ if (snapshot) {
+ /* pbx_exec sets application name and data, but we don't want to log
+ * every exec. Just update the snapshot here instead.
+ */
+ ast_string_field_set(snapshot, appl, app);
+ ast_string_field_set(snapshot, data, !ast_strlen_zero(appdata) ? appdata : "(NULL)");
+ msg = stasis_message_create(ast_channel_snapshot(), snapshot);
+ if (msg) {
+ stasis_publish(ast_channel_topic(chan), msg);
+ }
+ }
res = pbx_exec(chan, a, appdata);
} else
ast_log(LOG_NOTICE, "No such application '%s' for extension '%s' in context '%s'\n", app, exten, context);