#pragma once
// control_domain_server.hpp

#include <atomic>
#include <cstdint>
#include "frame_codec.hpp"
#include "control_handler.hpp"

namespace vaw
{

class ControlDomainServer
{
public:
    explicit ControlDomainServer(uint16_t port, ControlHandler* handler);
    ~ControlDomainServer();

    // 阻塞运行，直到 stop() 被调用
    void run();
    void stop();

private:
    void handle_connection(sock_t conn);

    uint16_t        port_;
    ControlHandler* handler_;
    std::atomic<bool> running_;
    sock_t          listen_sock_;
};

}  // namespace vaw
