#include "asterisk.h"
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+ASTERISK_REGISTER_FILE()
#include "asterisk/astdb.h"
#include "asterisk/astobj2.h"
/*! Scheme for custom device states */
#define DEVICE_STATE_SCHEME_STASIS "Stasis:"
/*! Scheme for device state subscriptions */
-#define DEVICE_STATE_SCHEME_SUB "device_state:"
+#define DEVICE_STATE_SCHEME_SUB "deviceState:"
/*! Number of hash buckets for device state subscriptions */
#define DEVICE_STATE_BUCKETS 37
static void device_state_subscription_destroy(void *obj)
{
struct device_state_subscription *sub = obj;
- sub->sub = stasis_unsubscribe(sub->sub);
+ sub->sub = stasis_unsubscribe_and_join(sub->sub);
ast_string_field_free_memory(sub);
}
ast_debug(3, "Subscribing to device %s", sub->device_name);
if (is_subscribed_device_state(app, sub->device_name)) {
- ast_log(LOG_WARNING, "Already subscribed to %s\n", sub->device_name);
- return -1;
+ ast_debug(3, "App %s is already subscribed to %s\n", stasis_app_name(app), sub->device_name);
+ return 0;
}
- if (!(sub->sub = stasis_subscribe(
+ if (!(sub->sub = stasis_subscribe_pool(
ast_device_state_topic(sub->device_name),
device_state_cb, sub))) {
ast_log(LOG_ERROR, "Unable to subscribe to device %s\n",
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Stasis application device state support",
+ .support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module,
.unload = unload_module,
- .nonoptreq = "res_stasis");
+ .nonoptreq = "res_stasis"
+);