+ struct closure_data *cdata;
+
+ /* tentatively store the client and client context, as the afb_req_t
+ * request will no longer be available in the async callback handler. This
+ * is similar to that is done showWindow(), handleRequest() in
+ * homescreen.cpp, but allows to fake the subscription here as well to
+ * avoid clients create/install dummy event handlers as to 'register' (or
+ * to keep track of applications started).
+ *
+ * In case api_callback() does return an error we'll remove then the client
+ * and client context there. We pass the closure_data with the client context
+ * and the application id to remove it.
+ */
+ if (!instance)
+ return;
+
+ cdata = static_cast<struct closure_data *>(calloc(1, sizeof(*cdata)));
+ cdata->hs_instance = instance;
+ cdata->appid = id;
+
+ struct HS_ClientManager *clientManager = instance->client_manager;
+ if (!clientManager) {
+ return;
+ }
+
+ cdata->clientCtx = clientManager->createClientCtxt(request, id);
+ HS_Client *client = clientManager->addClient(request, id);
+ if (client) {
+ if (client->handleRequest(request, "subscribe"))
+ AFB_WARNING("Failed to handle subcribe\n");
+ }
+
+ api_call(request->api, _afm_main, __FUNCTION__, args, cdata);