From 4ed4c256c1a9ce5f238698661cbce6b09ba24cdf Mon Sep 17 00:00:00 2001 From: Kyle Johnsen Date: Wed, 2 Feb 2022 23:46:49 -0500 Subject: [PATCH] added room name to getroomdata response --- src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 30a7e91..ab90064 100644 --- a/src/main.rs +++ b/src/main.rs @@ -156,9 +156,9 @@ fn read_roomdata_message(stream: &mut TcpStream, client: &Arc){ //read the room name and append the client application - let mut room_name = read_short_string(stream); + let short_room_name = read_short_string(stream); let application = client.application.read().unwrap().to_string(); - room_name = format!("{}_{}", application, room_name); + let room_name = format!("{}_{}", application, short_room_name); println!("{}",&room_name); //we need to access the rooms list let rooms = client.rooms_mutex.read().unwrap(); @@ -168,6 +168,12 @@ fn read_roomdata_message(stream: &mut TcpStream, client: &Arc){ //form and send the message let mut write_buf = vec![]; write_buf.push(ToClientTCPMessageType::RoomData as u8); + + + let roomname_bytes = short_room_name.as_bytes(); + write_buf.push(roomname_bytes.len() as u8); + write_buf.extend_from_slice(&roomname_bytes); + let clients = room.clients.read().unwrap(); write_buf.extend_from_slice(&(clients.len() as u32).to_be_bytes()); for (_k,c) in clients.iter() {