aboutsummaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-02-08 22:24:58 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-02-11 19:44:43 -0800
commit84eac57632f4374d3114ae0586061fd6c0a43bc3 (patch)
treedc97506386582926224f0fe62200f60795b763bd /binding
parentb1634e9c58a8442391aa782f967ddc3f85cd5cd9 (diff)
binding: weather: trigger weather event on subscribe
Send current weather data to any new subscribers Bug-AGL: SPEC-1273 Change-Id: I96c92ba7e469a5cdc13c48694f1b0f2a42752b74 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r--binding/afm-weather-binding.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/binding/afm-weather-binding.c b/binding/afm-weather-binding.c
index e2094c0..1103722 100644
--- a/binding/afm-weather-binding.c
+++ b/binding/afm-weather-binding.c
@@ -223,8 +223,16 @@ static void subscribe(struct afb_req request)
const char *value = afb_req_value(request, "value");
if (value && !strcasecmp(value, "weather")) {
+ json_object *jresp = NULL;
+
afb_req_subscribe(request, weather_event);
afb_req_success(request, NULL, NULL);
+
+ jresp = json_tokener_parse(data.buffer);
+ if (jresp) {
+ json_object_object_add(jresp, "url", json_object_new_string(data.url));
+ afb_event_push(weather_event, jresp);
+ }
return;
}