From 9a745bb56d592f9b02f94c1d681fe607670fae02 Mon Sep 17 00:00:00 2001 From: stale Date: Thu, 30 Jun 2022 07:18:45 -0300 Subject: clippy fixes and version bump --- src/conn.rs | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src/conn.rs') diff --git a/src/conn.rs b/src/conn.rs index f67121b..addf3c5 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -8,7 +8,6 @@ use tokio::sync::mpsc as tokio_mpsc; use futures::{SinkExt, StreamExt, TryStreamExt, stream::SplitStream}; use warp::ws::{ WebSocket, Message }; use crate::livepos; -use ammonia; const MAX_IN: usize = 2048; @@ -94,25 +93,10 @@ pub async fn handle_room(streams: RoomStreams, addr: SocketAddr, rinfo: (RoomId, match players_lock.get_mut(&addr) { Some(me) => match cmd_name { "pos" => { - match parse_pos(fields) { - Some(pos) => { - if let Err(e) = pos_tx.send(livepos::Req { id: me.uid, data: livepos::ReqData::Pos(pos) }) { - println!("{room_id} E: couldn't process {me}'s position update: {e}"); - }; - // me.position = pos.clone(); - // let sanitized_name = me.name.replace(" ", " ").to_string(); - // let msg = format!("pos {} {sanitized_name} {} {} {}", me.uid, me.clr, pos.0, pos.1); - // for peer_tx in players_lock.iter().filter(|(s, _)| **s != addr).map(|(_,p)| &p.conn.tx) { - // let r = peer_tx.send(Message::text(&msg)); - // if let Err(e) = r { - // println!("{room_id} E: error sending pos update: {e}"); - // } - // } - }, - None => { - // Too spammy - //println!("{room_id} E: bad position update from {me}"); - }, + if let Some(pos) = parse_pos(fields) { + if let Err(e) = pos_tx.send(livepos::Req { id: me.uid, data: livepos::ReqData::Pos(pos) }) { + println!("{room_id} E: couldn't process {me}'s position update: {e}"); + }; } }, "reveal" => { @@ -168,7 +152,7 @@ pub async fn handle_room(streams: RoomStreams, addr: SocketAddr, rinfo: (RoomId, let players_lock = players.read().await; let me = players_lock.get(&addr).unwrap(); tx.send(Message::text(format!("regack {} {} {} {}", - room_conf.name.replace(" ", " "), name.replace(" ", " "), uid, room_conf.board_conf)) + room_conf.name.replace(' ', " "), name.replace(' ', " "), uid, room_conf.board_conf)) ).expect("couldn't send register ack"); { @@ -201,7 +185,7 @@ pub async fn handle_room(streams: RoomStreams, addr: SocketAddr, rinfo: (RoomId, fn jsonenc_players<'a, I: IntoIterator>(players: I) -> Result { let mut pairs = Vec::new(); for player in players { - pairs.push((player.uid, player.name.replace(" ", " "), player.clr.clone())); + pairs.push((player.uid, player.name.replace(' ', " "), player.clr.clone())); } serde_json::to_string(&pairs) } -- cgit v1.2.3