diff options
author | Matthew Jordan <mjordan@digium.com> | 2013-05-17 17:43:58 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2013-05-17 17:43:58 +0000 |
commit | d04f1fd60a5f5a6e358fbe5a59ae8f42d21cbbdf (patch) | |
tree | fd3e01c6b7b34f35f5d020bbfa641898de104147 /main/stasis_channels.c | |
parent | b90bba7a303bf57c3c874a1c8f506d39d4e78a9c (diff) |
Publish the outbound channel's application/data when dialing
This patch does two things:
* It fixes a bug where the outbound channel's application/data set by the
dialing API/app_dial is not communicated until the channel is hung up.
If that happens, AMI would incorrectly send a NewExten event immediately
after a Hangup. This isn't really AMI's fault, as the dialing APIs never
communicated the 'helpful' app/data on the outbound channel until it was
hungup.
* It makes public sending a stasis message about a change in channel state.
This is useful enough that - for now at least - it should be public. If
operations on a channel go to being more coarse-grained, this function
could be made private again.
Review: https://reviewboard.asterisk.org/r/2548
Note that this problem was found and reported by Matt DiMeo.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388976 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/stasis_channels.c')
-rw-r--r-- | main/stasis_channels.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/main/stasis_channels.c b/main/stasis_channels.c index acae81939..3df52d0b3 100644 --- a/main/stasis_channels.c +++ b/main/stasis_channels.c @@ -417,6 +417,30 @@ void ast_channel_publish_varset(struct ast_channel *chan, const char *name, cons publish_message_for_channel_topics(msg, chan); } +void ast_publish_channel_state(struct ast_channel *chan) +{ + RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup); + RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup); + + ast_assert(chan != NULL); + if (!chan) { + return; + } + + snapshot = ast_channel_snapshot_create(chan); + if (!snapshot) { + return; + } + + message = stasis_message_create(ast_channel_snapshot_type(), snapshot); + if (!message) { + return; + } + + ast_assert(ast_channel_topic(chan) != NULL); + stasis_publish(ast_channel_topic(chan), message); +} + struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot) { RAII_VAR(struct ast_json *, json_chan, NULL, ast_json_unref); |