Files
voice-cat/server/src/server.h

45 lines
1.2 KiB
C
Raw Normal View History

/*
2026-06-15 23:48:44 +02:00
* server/server.h VoiceCat server entry point.
*
2026-06-15 23:48:44 +02:00
* 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 <cstdint>
2026-06-15 23:48:44 +02:00
#include <functional>
#include <mutex>
#include <string>
namespace voicecat::server {
struct Config {
std::string server_name = "VoiceCat Server";
2026-06-15 23:48:44 +02:00
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<void(uint16_t)> on_ready;
};
class Server {
public:
explicit Server(Config cfg) : cfg_(std::move(cfg)) {}
2026-06-15 23:48:44 +02:00
// Block until the server shuts down. Returns process exit code.
int run();
2026-06-15 23:48:44 +02:00
// Thread-safe stop: unblocks run() from any thread. No-op if not running.
void stop();
private:
2026-06-15 23:48:44 +02:00
Config cfg_;
std::mutex stop_mutex_;
std::function<void()> stop_fn_;
};
} // namespace voicecat::server
#endif // VOICECAT_SERVER_SERVER_H