summaryrefslogtreecommitdiff
path: root/ubusd_proto.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-12-14 13:00:49 +0100
committerFelix Fietkau <nbd@openwrt.org>2012-12-14 13:00:57 +0100
commita69f062cbd4041229f8d29ef9647bf783df414c1 (patch)
tree8bd1b500273b62708f51690d985397fada56337b /ubusd_proto.c
parentd366a6de839087d8a17e5855c14ae55e95b13c65 (diff)
downloadubus-a69f062cbd4041229f8d29ef9647bf783df414c1.tar.gz
ubus: add notification for subscribers present/gone
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'ubusd_proto.c')
-rw-r--r--ubusd_proto.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ubusd_proto.c b/ubusd_proto.c
index 59920ed..283cb77 100644
--- a/ubusd_proto.c
+++ b/ubusd_proto.c
@@ -416,6 +416,20 @@ void ubusd_proto_free_client(struct ubus_client *cl)
ubus_free_id(&clients, &cl->id);
}
+void ubus_notify_subscription(struct ubus_object *obj)
+{
+ bool active = !list_empty(&obj->subscribers);
+ struct ubus_msg_buf *ub;
+
+ blob_buf_init(&b, 0);
+ blob_put_int32(&b, UBUS_ATTR_OBJID, obj->id.id);
+ blob_put_int8(&b, UBUS_ATTR_ACTIVE, active);
+
+ ub = ubus_msg_from_blob(false);
+ ubus_msg_init(ub, UBUS_MSG_NOTIFY, ++obj->invoke_seq, 0);
+ ubus_msg_send(obj->client, ub, true);
+}
+
void ubus_notify_unsubscribe(struct ubus_subscription *s)
{
struct ubus_msg_buf *ub;