From 47b2b1512484d66cd92ea38b27f94d4dd70cd0b6 Mon Sep 17 00:00:00 2001 From: stale Date: Tue, 31 May 2022 15:49:57 -0300 Subject: changed log style, implemented room player limits --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 36ee5ce..9c9e5b1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,9 @@ async fn tokio_main(conf: Config) -> Result<(), Box> { .then(|(id, _):(&RoomId,_)| { let roomsl = roomsl.clone(); async move { - (id.clone(), roomsl.get(id).unwrap().read().await.players.read().await.len()) + let room = roomsl.get(id).unwrap().read().await; + let pcount = room.players.read().await.len(); + (id.clone(), (pcount, room.conf.player_cap)) } }) .collect::>().await; @@ -157,13 +159,13 @@ async fn tokio_main(conf: Config) -> Result<(), Box> { let id = RoomId {0: id}; match rooms.read().await.get(&id).map(|x| x.clone()) { Some(r) => { - println!("conn from {saddr:?} into {id}"); + println!("{id} I: conn from {saddr:?}"); Ok(websocket.on_upgrade(move |socket| { - conn::lobby(socket, saddr.expect("socket without address"), r.clone()) + conn::lobby(socket, saddr.expect("socket without address"), (id,r.clone())) })) }, None => { - println!("conn from {saddr:?} into inexistent room {id}"); + println!("I: conn from {saddr:?} into inexistent room {id}"); Err(reject()) } } -- cgit v1.2.3