/* * server/server.h — VoiceCat server entry point. * * Design: docs/architecture.md §5. Headless process: TLS control listener, * session registry, text relay, SQLite persistence. Zero-config first-run. */ #ifndef VOICECAT_SERVER_SERVER_H #define VOICECAT_SERVER_SERVER_H #include #include #include #include namespace voicecat::server { struct Config { std::string server_name = "VoiceCat Server"; std::string data_dir = "voicecat-data"; uint16_t bind_port = 8384; // 0 = let OS pick (useful for tests) bool allow_guests = true; // Called with the actual bound port once the acceptor is ready (m1-dev only). std::function on_ready; }; class Server { public: explicit Server(Config cfg) : cfg_(std::move(cfg)) {} // Block until the server shuts down. Returns process exit code. int run(); // Thread-safe stop: unblocks run() from any thread. No-op if not running. void stop(); private: Config cfg_; std::mutex stop_mutex_; std::function stop_fn_; }; } // namespace voicecat::server #endif // VOICECAT_SERVER_SERVER_H