diff --git a/src/handlers.rs b/src/handlers.rs index 85a7f3c..f856c3e 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -1,3 +1,4 @@ +// TODO: Fix screen sharing and video aspect ratio refinements if needed further use axum::{ extract::ws::{Message, WebSocket}, }; @@ -97,6 +98,23 @@ pub async fn handle_socket(mut socket: WebSocket, _addr: SocketAddr, state: AppS let _ = room.tx.send(control); } } + ControlMsg::ChatMessage { message, display_name, .. } => { + // Broadcast chat with sender info + let chat = ControlMsg::ChatMessage { + user_id: uid, + display_name: state.rooms.get(&rid) + .and_then(|r| r.peers.get(&uid).map(|p| p.display_name.clone())) + .unwrap_or(display_name), // Fallback to provided name + message, + timestamp: std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_millis() as u64, + }; + if let Some(room) = state.rooms.get(&rid) { + let _ = room.tx.send(chat); + } + } _ => {} } } diff --git a/src/udp.rs b/src/udp.rs index b85599f..0a83022 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -21,8 +21,6 @@ pub async fn run_udp_server(state: AppState) -> anyhow::Result<()> { match socket.recv_from(&mut buf).await { Ok((len, addr)) => { let data = &buf[..len]; - - info!("UDP Recv: {} bytes from {}", len, addr); // Log every packet for debug // Manually parse header (22 bytes) to match client's raw byte layout: // Byte 0: version (u8) @@ -57,8 +55,7 @@ pub async fn run_udp_server(state: AppState) -> anyhow::Result<()> { }; let payload = &data[22..]; - - info!("UDP: v{} type={:?} user={} len={}", version, media_type, user_id, data.len()); + match media_type { MediaType::Command => {