summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstale <redkugelblitzin@gmail.com>2022-07-03 04:24:51 -0300
committerstale <redkugelblitzin@gmail.com>2022-07-03 04:24:51 -0300
commitf8735f5b539b991f8da9ec1b3e64966566d77477 (patch)
tree6a5a87bcabbff808a200bddc372ebca7ae420f83 /src
parente933ae3795a27a0fad1f37189670c993d8b65f47 (diff)
sounds!
Diffstat (limited to 'src')
-rw-r--r--src/conn.rs3
-rw-r--r--src/main.rs10
2 files changed, 9 insertions, 4 deletions
diff --git a/src/conn.rs b/src/conn.rs
index 047d7db..89fd5e0 100644
--- a/src/conn.rs
+++ b/src/conn.rs
@@ -83,6 +83,9 @@ pub async fn drive_conn(conn: (Conn, SplitStream<WebSocket>), rinfo: (RoomId, Ar
x.zip(y)
};
if let Some(cmd_name) = fields.next() {
+ if cmd_name == "<3" {
+ continue; // heartbeat, no need to handle it
+ }
use crate::minesweeper::{Move,MoveType};
let mut players_lock = players.write().await;
match players_lock.get_mut(&conn.addr) {
diff --git a/src/main.rs b/src/main.rs
index 2321289..e4ccc56 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -127,11 +127,13 @@ async fn tokio_main(conf: Conf) -> Result<(), Box<dyn Error>> {
let uid = RoomId::new_among(rooms.keys());
match room_from_form(uid.clone(), &rinfo, &conf) {
- Ok((room, access)) => {
- if access {
+ Ok((room, public)) => {
+ if public {
pubs.write().await.insert(uid.clone(), serde_json::to_string(&room.conf).unwrap());
+ println!("New public room: {:?}", room.conf);
+ } else {
+ println!("New private room: {:?}", room.conf);
}
- println!("New room: {:?}", room.conf);
rooms.insert(uid.clone(), Arc::new(RwLock::new(room)));
Ok(
@@ -300,8 +302,8 @@ fn room_from_form(uid: RoomId, rinfo: &HashMap<String,String>, conf: &Conf) -> R
rinfo.get("mineratio-n").and_then(|n| n.parse::<usize>().ok()),
rinfo.get("mineratio-d").and_then(|d| d.parse::<NonZeroUsize>().ok()),
rinfo.get("public").map(|s| s == "on").unwrap_or(false),
- rinfo.get("rborders").map(|s| s == "on").unwrap_or(false),
rinfo.get("allsafe1move").map(|s| s == "on").unwrap_or(false),
+ rinfo.get("rborders").map(|s| s == "on").unwrap_or(false),
rinfo.get("limit").and_then(|l| l.parse::<NonZeroUsize>().ok()),
) {
if w.get()*h.get() > conf.limits.board_area {