summaryrefslogtreecommitdiff
path: root/src/conn.rs
diff options
context:
space:
mode:
authorstale <redkugelblitzin@gmail.com>2022-06-30 07:18:45 -0300
committerstale <redkugelblitzin@gmail.com>2022-06-30 07:18:45 -0300
commit9a745bb56d592f9b02f94c1d681fe607670fae02 (patch)
treec8d0ba62c39b22fc3f1c20d88fa1178b8f03f68d /src/conn.rs
parentf70c1df91afa0a211de0b743da6c0dad59fd23be (diff)
clippy fixes and version bumpHEADmaster
Diffstat (limited to 'src/conn.rs')
-rw-r--r--src/conn.rs28
1 files changed, 6 insertions, 22 deletions
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(" ", "&nbsp").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(" ", "&nbsp;"), name.replace(" ", "&nbsp;"), uid, room_conf.board_conf))
+ room_conf.name.replace(' ', "&nbsp;"), name.replace(' ', "&nbsp;"), 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<Item=&'a Player>>(players: I) -> Result<String, serde_json::Error> {
let mut pairs = Vec::new();
for player in players {
- pairs.push((player.uid, player.name.replace(" ", "&nbsp"), player.clr.clone()));
+ pairs.push((player.uid, player.name.replace(' ', "&nbsp"), player.clr.clone()));
}
serde_json::to_string(&pairs)
}