2 * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
18 static struct ubus_context *ctx;
19 static struct blob_buf b;
21 static void test_client_subscribe_cb(struct ubus_context *ctx, struct ubus_object *obj)
23 fprintf(stderr, "Subscribers active: %d\n", obj->has_subscribers);
26 static struct ubus_object test_client_object = {
27 .subscribe_cb = test_client_subscribe_cb,
30 static void client_main(void)
35 ret = ubus_add_object(ctx, &test_client_object);
37 fprintf(stderr, "Failed to add_object object: %s\n", ubus_strerror(ret));
41 if (ubus_lookup_id(ctx, "test", &id)) {
42 fprintf(stderr, "Failed to look up test object\n");
47 blobmsg_add_u32(&b, "id", test_client_object.id);
48 ubus_invoke(ctx, id, "watch", b.head, NULL, 0, 3000);
52 int main(int argc, char **argv)
54 const char *ubus_socket = NULL;
57 while ((ch = getopt(argc, argv, "cs:")) != -1) {
72 ctx = ubus_connect(ubus_socket);
74 fprintf(stderr, "Failed to connect to ubus\n");