diff options
author | Joshua Colp <jcolp@digium.com> | 2013-06-13 11:02:16 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2013-06-13 11:02:16 +0000 |
commit | 65c492e851639897d8db79741bdcebc3557ad29d (patch) | |
tree | ca67c5c9f3765f2dc4a45f2a4bdbc85c8d8b6fdd /main/endpoints.c | |
parent | 1e9faaf78a9caa4f03f456bf027aa139c31783f2 (diff) |
Add support for requiring that all queued messages on a caching topic have been handled before
retrieving from the cache and also change adding channels to an endpoint to be an immediate
operation.
Review: https://reviewboard.asterisk.org/r/2599/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@391596 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/endpoints.c')
-rw-r--r-- | main/endpoints.c | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/main/endpoints.c b/main/endpoints.c index 9f6d2c062..d689f2e6e 100644 --- a/main/endpoints.c +++ b/main/endpoints.c @@ -122,30 +122,23 @@ static void endpoint_dtor(void *obj) ast_string_field_free_memory(endpoint); } -static void endpoint_channel_snapshot(void *data, - struct stasis_subscription *sub, struct stasis_topic *topic, - struct stasis_message *message) -{ - struct ast_endpoint *endpoint = data; - struct ast_channel_snapshot *snapshot = stasis_message_data(message); - RAII_VAR(char *, existing_id, NULL, ao2_cleanup); - int publish = 0; +int ast_endpoint_add_channel(struct ast_endpoint *endpoint, + struct ast_channel *chan) +{ + ast_assert(chan != NULL); ast_assert(endpoint != NULL); - ast_assert(snapshot != NULL); + + ast_channel_forward_endpoint(chan, endpoint); ao2_lock(endpoint); - existing_id = ao2_find(endpoint->channel_ids, snapshot->uniqueid, - OBJ_POINTER); - if (!existing_id) { - ast_str_container_add(endpoint->channel_ids, - snapshot->uniqueid); - publish = 1; - } + ast_str_container_add(endpoint->channel_ids, ast_channel_uniqueid(chan)); ao2_unlock(endpoint); - if (publish) { - endpoint_publish_snapshot(endpoint); - } + + ast_publish_channel_state(chan); + endpoint_publish_snapshot(endpoint); + + return 0; } /*! \brief Handler for channel snapshot cache clears */ @@ -237,9 +230,6 @@ struct ast_endpoint *ast_endpoint_create(const char *tech, const char *resource) return NULL; } r |= stasis_message_router_add(endpoint->router, - ast_channel_snapshot_type(), endpoint_channel_snapshot, - endpoint); - r |= stasis_message_router_add(endpoint->router, stasis_cache_clear_type(), endpoint_cache_clear, endpoint); r |= stasis_message_router_set_default(endpoint->router, |