17 #ifndef LIBSOUNDMANAGER_H 18 #define LIBSOUNDMANAGER_H 23 #include <json-c/json.h> 24 #include <systemd/sd-event.h> 27 #include <afb/afb-binding.h> 28 #include <afb/afb-wsj1.h> 29 #include <afb/afb-ws-client.h> 39 int init(
int port,
const std::string& token);
49 int connect(
int sourceID,
int sinkID);
50 int connect(
int sourceID,
const std::string& sinkName);
54 int call(
const std::string& verb,
struct json_object* arg);
55 int call(
const char* verb,
struct json_object* arg);
56 int subscribe(
const std::string& event_name);
60 void (*event_cb)(
const std::string&
event,
struct json_object* event_contents),
61 void (*reply_cb)(
struct json_object* reply_contents),
62 void (*hangup_cb)(
void) =
nullptr);
64 void (*reply_cb)(
struct json_object* reply_contents),
65 void (*hangup_cb)(
void) =
nullptr);
69 int initialize_websocket();
70 int dispatch_event(
const std::string& event,
struct json_object* ev_contents);
72 void (*onEvent)(
const std::string& event,
struct json_object* event_contents);
73 void (*onReply)(
struct json_object* reply);
74 void (*onHangup)(void);
76 struct afb_wsj1* sp_websock;
77 struct afb_wsj1_itf minterface;
81 std::vector<int> msourceIDs;
82 std::map<EventType_SM, handler_fun> handlers;
87 void on_hangup(
void *closure,
struct afb_wsj1 *wsj);
88 void on_call(
void *closure,
const char *api,
const char *verb,
struct afb_wsj1_msg *msg);
89 void on_event(
void *closure,
const char *event,
struct afb_wsj1_msg *msg);
90 void on_reply(
void *closure,
struct afb_wsj1_msg *msg);
void register_callback(void(*event_cb)(const std::string &event, struct json_object *event_contents), void(*reply_cb)(struct json_object *reply_contents), void(*hangup_cb)(void)=nullptr)
void set_event_handler(enum EventType_SM et, handler_fun f)
int init(int port, const std::string &token)
int unsubscribe(const std::string &event_name)
int disconnect(int connectionID)
int call(const std::string &verb, struct json_object *arg)
int connect(int sourceID, int sinkID)
std::function< void(struct json_object *)> handler_fun
LibSoundmanager & operator=(const LibSoundmanager &)=delete
void on_hangup(void *closure, struct afb_wsj1 *wsj)
int subscribe(const std::string &event_name)
int ackSetSourceState(int handle, int error)
void on_reply(void *closure, struct afb_wsj1_msg *msg)
void on_call(void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg)
void on_event(void *closure, const char *event, struct afb_wsj1_msg *msg)
int registerSource(const std::string &sourceName)