return ret;
}
+
+/**
+ * push event
+ *
+ * #### Parameters
+ * - event : the event want to push
+ * - param : the parameter contents of event
+ * - appid : the destination application's id
+ *
+ * #### Return
+ * 0 : success
+ * others : fail
+ *
+ */
+int HS_ClientManager::pushEvent(const char *event, struct json_object *param, std::string appid)
+{
+ if(event == nullptr) {
+ HMI_ERROR("homescreen-service","event name is null.");
+ return -1;
+ }
+
+ if(appid.empty()) { // broadcast event to clients who subscribed this event
+ std::lock_guard<std::mutex> lock(this->mtx);
+ for(auto m : client_list) {
+ m.second->pushEvent(event, param);
+ }
+ }
+ else { // push event to specific client
+ std::lock_guard<std::mutex> lock(this->mtx);
+ auto ip = client_list.find(appid);
+ if(ip != client_list.end()) {
+ ip->second->pushEvent(event, param);
+ }
+ }
+
+ return 0;
+}