/* * session/session.h — client-side mirror of the server's channel/user state. * * Populated from ServerStateSnapshot (full snapshot) and incremental UserEvent / * ChannelEvent messages. Not thread-safe — always called from io_thread_. */ #ifndef VOICECAT_SESSION_SESSION_H #define VOICECAT_SESSION_SESSION_H #include #include #include #ifdef VOICECAT_HAS_NET #include "proto/voicecat.pb.h" #endif namespace voicecat::session { struct Channel { uint32_t id{0}; uint32_t parent_id{0}; std::string name; bool password_protected{false}; uint32_t max_users{0}; }; struct Stream { uint32_t stream_id{0}; uint32_t ssrc{0}; int kind{0}; std::string label; }; struct User { uint32_t id{0}; std::string nickname; bool is_guest{true}; uint32_t channel_id{0}; std::vector streams; }; class SessionModel { public: const std::vector& channels() const { return channels_; } const std::vector& users() const { return users_; } const Channel* find_channel(uint32_t id) const; const User* find_user(uint32_t id) const; #ifdef VOICECAT_HAS_NET void apply_snapshot(const voicecat::v1::ServerStateSnapshot& snap); void apply_user_event(const voicecat::v1::UserEvent& ev); void apply_channel_event(const voicecat::v1::ChannelEvent& ev); #endif private: std::vector channels_; std::vector users_; }; } // namespace voicecat::session #endif // VOICECAT_SESSION_SESSION_H