Files
DMF-Studio/libs/dmf-node/include/dmf-node/control_server.hpp
T
2026-05-28 23:43:26 +03:00

36 lines
791 B
C++

#pragma once
#include <dmf-node/node.hpp>
#include <functional>
#include <string>
#include <unordered_map>
#include <vector>
struct lws;
namespace dmf_node {
using CommandHandler = std::function<nlohmann::json(const nlohmann::json& payload)>;
using StatusCallback = std::function<void(const nlohmann::json& event)>;
class ControlServer {
public:
ControlServer(uint16_t port, StatusCallback on_event);
~ControlServer();
ControlServer(const ControlServer&) = delete;
ControlServer& operator=(const ControlServer&) = delete;
void register_command(const std::string& cmd, CommandHandler handler);
void send_event(const nlohmann::json& event);
void poll(int timeout_ms);
private:
struct Impl;
std::unique_ptr<Impl> impl_;
};
} // namespace dmf_node