summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer-binding.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-09-16 02:40:39 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-09-27 13:05:37 +0200
commit644318fecd112a60f364348c83aeac8a7db12aae (patch)
tree1f3aa880b47b4e3dabf81969e41a3b96e2fc380c /signal-composer-binding/signal-composer-binding.cpp
parent7138e18c162f9246079fbb077d38f7796314b6b0 (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.cpp17
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;