#pragma once
// chassis_domain_server.hpp

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

namespace vaw
{

class ChassisDomainServer
{
public:
    explicit ChassisDomainServer(uint16_t port, ChassisHandler* handler);
    ~ChassisDomainServer();

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

private:
    void handle_connection(sock_t conn);

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

}  // namespace vaw
