hs-proxy: Avoid creating a client context
[apps/agl-service-homescreen.git] / src / hs-clientmanager.cpp
index 9b62808..beac816 100644 (file)
@@ -95,6 +95,8 @@ HS_ClientCtxt* HS_ClientManager::createClientCtxt(afb_req_t req, std::string app
         afb_req_session_set_LOA(req, 1);
         afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
     }
+
+    appid2ctxt[appid] = ctxt;
     return ctxt;
 }
 
@@ -182,11 +184,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");
             }