Revert "Use appid between homescreen-service and apps"
[src/libhomescreen.git] / src / libhomescreen.cpp
index 66fd259..0462d4d 100644 (file)
@@ -175,7 +175,7 @@ int LibHomeScreen::initialize_websocket()
 
        /* Initialize interface from websocket */
        minterface.on_hangup = _on_hangup_static;
-       minterface.on_call = _on_call_static; /* Is this necessary? */
+       minterface.on_call = _on_call_static;
        minterface.on_event = _on_event_static;
        muri += "ws://localhost:" + to_string(mport) + "/api?token=" + mtoken; /*To be modified*/
        sp_websock = afb_ws_client_connect_wsj1(mploop, muri.c_str(), &minterface, this);
@@ -280,6 +280,10 @@ int LibHomeScreen::onScreenReply(const char* reply_message)
  *
  * #### Return
  * Nothing
+ *
+ * #### Note
+ * Don't release json_object by json_object_put in handler_func.
+ * The resource is released by libafbwsc library.
  */
 void LibHomeScreen::set_event_handler(enum EventType et, handler_func f)
 {
@@ -466,6 +470,9 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m
        const char* event_only = strchr(event, '/');
        if (event_only != nullptr) {
                event_only = event_only + 1;
+       }else{
+               HMI_WARNING("libhomescreen","event_only is null.");
+               return;
        }
 
        if (strcasecmp(event_only, LibHomeScreen::event_list[0].c_str()) == 0) {
@@ -486,8 +493,6 @@ void LibHomeScreen::on_event(void *closure, const char *event, struct afb_wsj1_m
                        i->second(json_data);
                }
        }
-
-       json_object_put(ev_contents);
 }
 
 /**
@@ -501,8 +506,6 @@ void LibHomeScreen::on_reply(void *closure, struct afb_wsj1_msg *msg)
        {
                struct json_object* reply = afb_wsj1_msg_object_j(msg);
                onReply(reply);
-
-               json_object_put(reply);
        }
 }