hs-clientmanager: Do not store always the client context
[apps/agl-service-homescreen.git] / src / hs-clientmanager.cpp
index 9b62808..e880c62 100644 (file)
@@ -94,7 +94,10 @@ HS_ClientCtxt* HS_ClientManager::createClientCtxt(afb_req_t req, std::string app
         ctxt = new HS_ClientCtxt(appid);
         afb_req_session_set_LOA(req, 1);
         afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
+
+       appid2ctxt[appid] = ctxt;
     }
+
     return ctxt;
 }
 
@@ -182,11 +185,12 @@ int HS_ClientManager::handleRequest(afb_req_t request, const char *verb, const c
         std::string id(appid);
         auto ip = client_list.find(id);
         if(ip != client_list.end()) {
+           // FIXME: do another verification here in case the application died
             ret = ip->second->handleRequest(request, verb);
         }
         else {
             if(!strcasecmp(verb, "subscribe")) {
-                appid2ctxt[id] = createClientCtxt(request, id);
+                createClientCtxt(request, id);
                 HS_Client* client = addClient(request, id);
                 ret = client->handleRequest(request, "subscribe");
             }