diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-09-16 02:40:39 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-09-27 13:05:37 +0200 |
commit | 644318fecd112a60f364348c83aeac8a7db12aae (patch) | |
tree | 1f3aa880b47b4e3dabf81969e41a3b96e2fc380c /signal-composer-binding/signal-composer-binding.cpp | |
parent | 7138e18c162f9246079fbb077d38f7796314b6b0 (diff) |
More accurate (un)subscribe answer
Answer a failure when attempting to subscibe a non-existent
signal but don't report error on unsubscription.
Change-Id: Iac4bfe52ce84b47fbfa5717cd9ee2bf02231f52f
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer-binding.cpp')
-rw-r--r-- | signal-composer-binding/signal-composer-binding.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp index 310cb40..7d3391b 100644 --- a/signal-composer-binding/signal-composer-binding.cpp +++ b/signal-composer-binding/signal-composer-binding.cpp @@ -83,15 +83,22 @@ static int one_subscribe_unsubscribe(struct afb_req request, int err = 0; std::vector<std::shared_ptr<Signal>> signals = Composer::instance().searchSignals(event); - if(subscribe) + if(signals.size() == 0 && subscribe) { - cContext->appendSignals(signals); - err = cContext->makeSubscription(request); + err--; } else { - cContext->subtractSignals(signals); - err = cContext->makeUnsubscription(request); + if(subscribe) + { + cContext->appendSignals(signals); + err = cContext->makeSubscription(request); + } + else + { + cContext->subtractSignals(signals); + err = cContext->makeUnsubscription(request); + } } return err; |