/*
* Copyright (c) 2018 TOYOTA MOTOR CORPORATION
+ * Copyright (C) 2020 Konsulko Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define HOMESCREEN_CLIENTMANAGER_H
#include <string>
-#include <vector>
#include <mutex>
#include <memory>
#include <unordered_map>
#include "hs-helper.h"
#include "hs-client.h"
-typedef struct HS_ClientCtxt
-{
+struct HS_ClientCtxt {
std::string id;
- HS_ClientCtxt(const char *appid)
+ HS_ClientCtxt(const std::string &appid)
{
id = appid;
}
-} HS_ClientCtxt;
+};
class HS_ClientManager {
static HS_ClientManager* instance(void);
int init(void);
- HS_Client* find(std::string appid);
- HS_Client* getClient(afb_req req, std::string appid);
- std::vector<HS_Client*> getAllClient(void);
- void removeClientCtxt(void *data);
+ int handleRequest(afb_req_t request, const char *verb, const char *appid = nullptr);
+ int pushEvent(const char *event, struct json_object *param, std::string appid = "");
+ void removeClientCtxt(void *data); // don't use, internal only
-private:
- HS_ClientCtxt* createClientCtxt(afb_req req, std::string appid);
- HS_Client* addClient(afb_req req, std::string appid);
+ HS_ClientCtxt* createClientCtxt(afb_req_t req, std::string appid);
+ HS_Client* addClient(afb_req_t req, std::string appid);
void removeClient(std::string appid);
private:
std::mutex mtx;
};
-#endif // HOMESCREEN_CLIENTMANAGER_H
\ No newline at end of file
+#endif // HOMESCREEN_CLIENTMANAGER_H