From 83047fe488bdc368bcb514f7ba129fa86955916c Mon Sep 17 00:00:00 2001 From: Leo dev Date: Wed, 7 Jan 2026 17:10:55 +0100 Subject: [PATCH] Initial voice chat --- src/server.rs | 1 + src/types.rs | 3 +++ src/utils/voice.rs | 11 ++++------- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/server.rs b/src/server.rs index 525bb03..6b11b71 100644 --- a/src/server.rs +++ b/src/server.rs @@ -175,6 +175,7 @@ impl Server { client.send(types::message::ServerMessage::Authenticated { uuid, indicators: self.indicators.lock().unwrap().clone(), + voice_chat: self.voice.lock().unwrap().get_connections(), }), )?; } diff --git a/src/types.rs b/src/types.rs index 169bd82..639f8d0 100644 --- a/src/types.rs +++ b/src/types.rs @@ -53,6 +53,8 @@ pub mod handshake { } pub mod message { + use std::collections::HashMap; + use serde::{Deserialize, Serialize}; use crate::{ @@ -110,6 +112,7 @@ pub mod message { Authenticated { uuid: Author, indicators: Vec, + voice_chat: HashMap>, }, TempMessage { diff --git a/src/utils/voice.rs b/src/utils/voice.rs index 245540f..ad8eb11 100644 --- a/src/utils/voice.rs +++ b/src/utils/voice.rs @@ -46,16 +46,13 @@ impl Voice { .unwrap_or_default() } - /// Check if a user exists in a channel - pub fn check(&self, channel_id: &str, user_id: &str) -> Option { - self.connections - .get(channel_id) - .and_then(|users| users.get(user_id).copied()) - } - pub fn find_user(&self, user_id: &str) -> Option<(&String, u16)> { self.connections .iter() .find_map(|(channel_id, users)| users.get(user_id).map(|v| (channel_id, *v))) } + + pub fn get_connections(&self) -> HashMap> { + self.connections.clone() + } }