type UserId = u16;
type ChannelId = u16;
// GLOBAL & LOCAL are always registered and do not send a
// ChannelNew/ChannelRemoved message.
// ChannelList also does not return them.
// GLOBAL channel means broadcasting to all other users, like in a global lobby
const GLOBAL: ChannelId = 0;
// LOCAL is the spatial user output, usually setup from a entity that represent
// the user
const LOCAL: ChannelId = 1;
// This is the first channel that can be custom defined, all ids lower than
// this are reserved by the crate internals.
const CUSTOM_START: ChannelId = 8;
struct User {
id: UserId,
name: String,
}
struct Channel {
id: ChannelId,
name: String,
// For spatial outputs, eg characters speaking in world, need to bind this
// channel to a specific uuid. The uuid is global, the Entity local.
entity: Option<Uuid>,
}
enum Destination {
User(UserId),
Channel(ChannelId),
}
struct AudioPacket {
from: UserId,
to: Destination,
audio_chunk: Vec<f32>,
}
enum AudioMessage {
RequestNewUserHandle(String),
UserHandle(UserId),
UserNew(User),
UserRemoved(UserId),
ChannelNew(Channel),
ChannelRemoved(ChannelId),
RequestChannelList,
ChannelList(Vec<Channel>),
UserJoinedChannel(UserId, ChannelId),
UserLeftChannel(UserId, ChannelId),
Audio(AudioPacket),
}