diff options
| author | Fuwn <[email protected]> | 2021-03-29 22:59:58 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-03-29 22:59:58 +0000 |
| commit | 2a448f3c05fa8ccfe6be82fb66b260b0de93d2a8 (patch) | |
| tree | d6a53d8cdc51c2891285df8890b658894b34f335 /src/server | |
| parent | format: Fix a few Clippy warnings (diff) | |
| download | whirl-2a448f3c05fa8ccfe6be82fb66b260b0de93d2a8.tar.xz whirl-2a448f3c05fa8ccfe6be82fb66b260b0de93d2a8.zip | |
feature: Reimplement room ID request command branch to command handler
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/room/server.rs | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/server/room/server.rs b/src/server/room/server.rs index 2302085..df55415 100644 --- a/src/server/room/server.rs +++ b/src/server/room/server.rs @@ -108,32 +108,32 @@ impl RoomServer { .await?; debug!("sent buddy list notify command to client: {}", received_buddy); } - // 20 => { // ROOMIDRQ - // let room_name = from_utf8( - // msg.get(4..msg.get(0).unwrap().to_owned() as usize).unwrap() - // ).unwrap(); - // debug!("received room id request command from client: {}", room_name); - // let room_id; - // if !room_ids.contains(&room_name.to_string()) { - // room_ids.push(room_name.to_string()); - // room_id = room_ids.iter() - // .position(|i| i == &room_name.to_string()) - // .unwrap(); - // trace!("inserted room '{}' as '{}'", room_name, room_id); - // } else { - // let position = room_ids.iter() - // .position(|i| i == &room_name.to_string()) - // .unwrap(); - // trace!("found room '{}' as '{}'", room_name, position); - // room_id = position; - // } - // trace!("room name: {}, room id: {}", room_name, room_id); - // trace!("{:?}", room_ids); - // peer.bytes.get_mut() - // .write_all(&create_room_id_redirect_command(room_name, room_id)) - // .await?; - // debug!("sent redirect id command to client: {} == {}", room_name, room_id); - // } + 20 => { // ROOMIDRQ + let room_name = from_utf8( + msg.get(4..msg.get(0).unwrap().to_owned() as usize).unwrap() + ).unwrap(); + debug!("received room id request command from client: {}", room_name); + let room_id; + if !room_ids.contains(&room_name.to_string()) { + room_ids.push(room_name.to_string()); + room_id = room_ids.iter() + .position(|i| i == &room_name.to_string()) + .unwrap(); + trace!("inserted room '{}' as '{}'", room_name, room_id); + } else { + let position = room_ids.iter() + .position(|i| i == &room_name.to_string()) + .unwrap(); + trace!("found room '{}' as '{}'", room_name, position); + room_id = position; + } + trace!("room name: {}, room id: {}", room_name, room_id); + trace!("{:?}", room_ids); + peer.bytes.get_mut() + .write_all(&create_room_id_redirect_command(room_name, room_id)) + .await?; + debug!("sent redirect id command to client: {} == {}", room_name, room_id); + } 14 => { let text = from_utf8( msg.get(6..msg.get(0).unwrap().to_owned() as usize).unwrap() |