diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-09-22 09:23:11 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-14 11:00:25 +0100 |
commit | e4258ef6e45009b5625f85ec7e4f8946805e1c4a (patch) | |
tree | 90cede1867442e0437aa240d6acc8e5ca40ef5fd /signal-composer-binding/signal-composer.cpp | |
parent | 960d051d0a20b7146617880d30ad2496afa1f5e5 (diff) |
Subscribe
Change-Id: I7bbe972254d60f89cb26c98ea8519af087d8ae90
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer.cpp')
-rw-r--r-- | signal-composer-binding/signal-composer.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp index c6ffdd4..ba1b406 100644 --- a/signal-composer-binding/signal-composer.cpp +++ b/signal-composer-binding/signal-composer.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ +#include <uuid.h> #include <string.h> #include <fnmatch.h> @@ -389,12 +390,12 @@ Composer& Composer::instance() void* Composer::createContext(void* ctx) { uuid_t x; + char cuid[38]; uuid_generate(x); ctx = (clientAppCtxT*)calloc(1, sizeof(clientAppCtxT)); clientAppCtxT* ret = (clientAppCtxT*) ctx; - uuid_copy(ret->uid, x); - ret->subscribedSignals = std::vector<std::shared_ptr<Signal>>(); - ret->event = afb_daemon_make_event("evt"); + uuid_unparse(x, cuid); + ret->event = afb_daemon_make_event(cuid); return (void*)ret; } @@ -543,7 +544,7 @@ json_object* Composer::getSignalValue(const std::string& sig, json_object* optio return response; } -int Composer::execSubscription() +int Composer::execSignalsSubscription() { int err = 0; for(SourceAPI& srcAPI: sourcesListV_) @@ -555,3 +556,18 @@ int Composer::execSubscription() } return err; } + +void Composer::addSubscription(clientAppCtxT* ctx) +{ + subscriptions_.push_back(ctx); +} + +void Composer::removeSubscription(clientAppCtxT* ctx) +{ + for(std::vector<clientAppCtxT*>::const_iterator i = subscriptions_.begin(); + i != subscriptions_.end(); ++i) + { + if(ctx == *i) + {subscriptions_.erase(i);} + } +} |