Simple voice test

This commit is contained in:
2026-01-06 18:37:24 +01:00
parent e0477a9575
commit 81c59a578d
2 changed files with 20 additions and 3 deletions
+5 -3
View File
@@ -1,6 +1,7 @@
pub mod chunk; pub mod chunk;
pub mod message;
pub mod indicator; pub mod indicator;
pub mod message;
pub mod voice;
use std::sync::Arc; use std::sync::Arc;
@@ -44,8 +45,9 @@ impl Server {
} }
}, },
WsMessage::Binary(b) => { WsMessage::Binary(data) => {
Self::LOGGER.info(format!("Binary message: {b:?}")); // Self::LOGGER.info(format!("Binary message: {data:?}"));
voice::voice(self, client, data)?;
} }
WsMessage::String(s) => { WsMessage::String(s) => {
+15
View File
@@ -0,0 +1,15 @@
use crate::{server::Server, utils::client::Client};
use std::sync::Arc;
crate::logger!(LOGGER "Voice chat");
pub fn voice(server: &Arc<Server>, client: &Client, data: &[u8]) -> crate::Result<()> {
let prefix = (10u16).to_le_bytes();
let mut payload = Vec::with_capacity(prefix.len() + data.len());
payload.extend_from_slice(&prefix);
payload.extend_from_slice(data);
client.send_bin(&payload)?;
Ok(())
}