Fix client disconnection close
[src/app-framework-binder.git] / src / main-afb-client-demo.c
index 47171c2..b772c9d 100644 (file)
@@ -60,7 +60,7 @@ static void on_pws_event_remove(void *closure, const char *event_name, int event
 static void on_pws_event_subscribe(void *closure, void *request, const char *event_name, int event_id);
 static void on_pws_event_unsubscribe(void *closure, void *request, const char *event_name, int event_id);
 static void on_pws_event_push(void *closure, const char *event_name, int event_id, struct json_object *data);
-static void on_pws_event_broadcast(void *closure, const char *event_name, struct json_object *data);
+static void on_pws_event_broadcast(void *closure, const char *event_name, struct json_object *data, const afb_proto_ws_uuid_t uuid, uint8_t hop);
 
 static void idle();
 static int process_stdin();
@@ -522,7 +522,7 @@ static void on_pws_event_push(void *closure, const char *event_name, int event_i
        fflush(stdout);
 }
 
-static void on_pws_event_broadcast(void *closure, const char *event_name, struct json_object *data)
+static void on_pws_event_broadcast(void *closure, const char *event_name, struct json_object *data, const afb_proto_ws_uuid_t uuid, uint8_t hop)
 {
        if (raw)
                printf("ON-EVENT-BROADCAST: [%s]\n%s\n", event_name, json_object_to_json_string_ext(data, JSON_C_TO_STRING_NOSLASHESCAPE));
@@ -538,6 +538,7 @@ static void pws_call(const char *verb, const char *object)
        char *key;
        int rc;
        struct json_object *o;
+       enum json_tokener_error jerr;
 
        /* allocates an id for the request */
        rc = asprintf(&key, "%d:%s", ++num, verb);
@@ -548,11 +549,11 @@ static void pws_call(const char *verb, const char *object)
 
        /* send the request */
        callcount++;
-       if (object == NULL || object[0] == 0 || !strcmp(object, "null"))
+       if (object == NULL || object[0] == 0)
                o = NULL;
        else {
-               o = json_tokener_parse(object);
-               if (!o)
+               o = json_tokener_parse_verbose(object, &jerr);
+               if (jerr != json_tokener_success)
                        o = json_object_new_string(object);
        }
        rc = afb_proto_ws_client_call(pws, verb, o, sessionid, key, NULL);