From ed483779946553e2ec42472c6b665b86dcb07066 Mon Sep 17 00:00:00 2001 From: Kevin Harwell Date: Sat, 23 Nov 2013 17:48:28 +0000 Subject: ARI: Implement device state API Created a data model and implemented functionality for an ARI device state resource. The following operations have been added that allow a user to manipulate an ARI controlled device: Create/Change the state of an ARI controlled device PUT /deviceStates/{deviceName}&{deviceState} Retrieve all ARI controlled devices GET /deviceStates Retrieve the current state of a device GET /deviceStates/{deviceName} Destroy a device-state controlled by ARI DELETE /deviceStates/{deviceName} The ARI controlled device must begin with 'Stasis:'. An example controlled device name would be Stasis:Example. A 'DeviceStateChanged' event has also been added so that an application can subscribe and receive device change events. Any device state, ARI controlled or not, can be subscribed to. While adding the event, the underlying subscription control mechanism was refactored so that all current and future resource subscriptions would be the same. Each event resource must now register itself in order to be able to properly handle [un]subscribes. (issue ASTERISK-22838) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/3025/ ........ Merged revisions 403134 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403135 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/devicestate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'main') diff --git a/main/devicestate.c b/main/devicestate.c index 158d1f817..7b52f00af 100644 --- a/main/devicestate.c +++ b/main/devicestate.c @@ -734,6 +734,22 @@ struct stasis_topic *ast_device_state_topic(const char *device) return stasis_topic_pool_get_topic(device_state_topic_pool, device); } +int ast_device_state_clear_cache(const char *device) +{ + RAII_VAR(struct stasis_message *, cached_msg, NULL, ao2_cleanup); + RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup); + + if (!(cached_msg = stasis_cache_get(ast_device_state_cache(), + ast_device_state_message_type(), device))) { + /* nothing to clear */ + return -1; + } + + msg = stasis_cache_clear_create(cached_msg); + stasis_publish(ast_device_state_topic(device), msg); + return 0; +} + int ast_publish_device_state_full( const char *device, enum ast_device_state state, -- cgit v1.2.3