2 * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
3 * Copyright (C) 2020 Konsulko Group
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef HOMESCREEN_CLIENTMANAGER_H
19 #define HOMESCREEN_CLIENTMANAGER_H
24 #include <unordered_map>
25 #include "hs-helper.h"
26 #include "hs-client.h"
28 struct HS_ClientCtxt {
30 HS_ClientCtxt(const std::string &appid)
37 class HS_ClientManager {
40 ~HS_ClientManager() = default;
41 HS_ClientManager(HS_ClientManager const &) = delete;
42 HS_ClientManager &operator=(HS_ClientManager const &) = delete;
43 HS_ClientManager(HS_ClientManager &&) = delete;
44 HS_ClientManager &operator=(HS_ClientManager &&) = delete;
46 static HS_ClientManager* instance(void);
48 int handleRequest(afb_req_t request, const char *verb, const char *appid = nullptr);
49 int pushEvent(const char *event, struct json_object *param, std::string appid = "");
50 void removeClientCtxt(void *data); // don't use, internal only
53 HS_ClientCtxt* createClientCtxt(afb_req_t req, std::string appid);
54 HS_Client* addClient(afb_req_t req, std::string appid);
55 void removeClient(std::string appid);
58 static HS_ClientManager* me;
59 std::unordered_map<std::string, HS_Client*> client_list;
60 std::unordered_map<std::string, HS_ClientCtxt*> appid2ctxt;
64 #endif // HOMESCREEN_CLIENTMANAGER_H