Initial voice chat

This commit is contained in:
2026-01-07 17:10:55 +01:00
parent 6e3d509742
commit 83047fe488
3 changed files with 8 additions and 7 deletions
+1
View File
@@ -175,6 +175,7 @@ impl Server {
client.send(types::message::ServerMessage::Authenticated { client.send(types::message::ServerMessage::Authenticated {
uuid, uuid,
indicators: self.indicators.lock().unwrap().clone(), indicators: self.indicators.lock().unwrap().clone(),
voice_chat: self.voice.lock().unwrap().get_connections(),
}), }),
)?; )?;
} }
+3
View File
@@ -53,6 +53,8 @@ pub mod handshake {
} }
pub mod message { pub mod message {
use std::collections::HashMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
@@ -110,6 +112,7 @@ pub mod message {
Authenticated { Authenticated {
uuid: Author, uuid: Author,
indicators: Vec<IndicatorContext>, indicators: Vec<IndicatorContext>,
voice_chat: HashMap<String, HashMap<String, u16>>,
}, },
TempMessage { TempMessage {
+4 -7
View File
@@ -46,16 +46,13 @@ impl Voice {
.unwrap_or_default() .unwrap_or_default()
} }
/// Check if a user exists in a channel
pub fn check(&self, channel_id: &str, user_id: &str) -> Option<u16> {
self.connections
.get(channel_id)
.and_then(|users| users.get(user_id).copied())
}
pub fn find_user(&self, user_id: &str) -> Option<(&String, u16)> { pub fn find_user(&self, user_id: &str) -> Option<(&String, u16)> {
self.connections self.connections
.iter() .iter()
.find_map(|(channel_id, users)| users.get(user_id).map(|v| (channel_id, *v))) .find_map(|(channel_id, users)| users.get(user_id).map(|v| (channel_id, *v)))
} }
pub fn get_connections(&self) -> HashMap<String, HashMap<String, u16>> {
self.connections.clone()
}
} }