diff options
author | stale <redkugelblitzin@gmail.com> | 2022-05-31 15:49:57 -0300 |
---|---|---|
committer | stale <redkugelblitzin@gmail.com> | 2022-05-31 15:49:57 -0300 |
commit | 47b2b1512484d66cd92ea38b27f94d4dd70cd0b6 (patch) | |
tree | 53dbaef77a9a97e188015731d9d397cd244161a7 /src/main.rs | |
parent | d9eededb736e4ada13ee6e7fe517adcc6a606f88 (diff) |
changed log style, implemented room player limits
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 6 insertions, 4 deletions
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<dyn Error>> { .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::<HashMap<RoomId,_>>().await; @@ -157,13 +159,13 @@ async fn tokio_main(conf: Config) -> Result<(), Box<dyn Error>> { 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()) } } |