X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhs-clientmanager.cpp;fp=src%2Fhs-clientmanager.cpp;h=9fe8b96daf233c10531a88d765dcd74c75b61f47;hb=0a47c007af262ac91bfa219a7b848aa0046005b3;hp=1355c99517c25169311f0e9987a97ce052739423;hpb=83cc1aeb7dcb0ce030a24f9aa079bb15bc2ef60a;p=apps%2Fagl-service-homescreen.git diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp index 1355c99..9fe8b96 100644 --- a/src/hs-clientmanager.cpp +++ b/src/hs-clientmanager.cpp @@ -463,3 +463,40 @@ int HS_ClientManager::showInformation(afb_req_t request) 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 lock(this->mtx); + for(auto m : client_list) { + m.second->pushEvent(event, param); + } + } + else { // push event to specific client + std::lock_guard lock(this->mtx); + auto ip = client_list.find(appid); + if(ip != client_list.end()) { + ip->second->pushEvent(event, param); + } + } + + return 0; +}