Files
voice-cat/core/src/session/session.h

65 lines
1.6 KiB
C
Raw Normal View History

/*
2026-06-15 23:48:44 +02:00
* session/session.h client-side mirror of the server's channel/user state.
*
2026-06-15 23:48:44 +02:00
* 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 <cstdint>
#include <string>
#include <vector>
2026-06-15 23:48:44 +02:00
#ifdef VOICECAT_HAS_NET
#include "proto/voicecat.pb.h"
#endif
namespace voicecat::session {
struct Channel {
2026-06-15 23:48:44 +02:00
uint32_t id{0};
uint32_t parent_id{0};
std::string name;
2026-06-15 23:48:44 +02:00
bool password_protected{false};
uint32_t max_users{0};
};
struct Stream {
2026-06-15 23:48:44 +02:00
uint32_t stream_id{0};
uint32_t ssrc{0};
int kind{0};
std::string label;
};
struct User {
2026-06-15 23:48:44 +02:00
uint32_t id{0};
std::string nickname;
bool is_guest{true};
uint32_t channel_id{0};
std::vector<Stream> streams;
};
class SessionModel {
public:
const std::vector<Channel>& channels() const { return channels_; }
2026-06-15 23:48:44 +02:00
const std::vector<User>& 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<Channel> channels_;
2026-06-15 23:48:44 +02:00
std::vector<User> users_;
};
} // namespace voicecat::session
#endif // VOICECAT_SESSION_SESSION_H