From f70c1df91afa0a211de0b743da6c0dad59fd23be Mon Sep 17 00:00:00 2001 From: stale Date: Thu, 30 Jun 2022 06:34:59 -0300 Subject: redid the live cursor position system --- src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 5012e95..82f1c8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ use std::{ use futures::stream::StreamExt; mod types; +mod livepos; mod conn; mod minesweeper; use types::*; @@ -129,9 +130,15 @@ async fn tokio_main(conf: Config) -> Result<(), Box> { let n = rinfo.get("rname").unwrap().to_owned(); if n.is_empty() { uid.to_string() } else { n } }; + let players = PlayerMap::default(); + let (cmd_tx, cmd_rx) = tokio::sync::mpsc::unbounded_channel(); - let handle = tokio::spawn(gameloop(cmd_rx, players.clone(), board_conf)); + let game_handle = tokio::spawn(gameloop(cmd_rx, players.clone(), board_conf)); + + let (pos_tx, pos_rx) = tokio::sync::mpsc::unbounded_channel(); + let livepos_handle = tokio::spawn(livepos::livepos(players.clone(), pos_rx)); + let room_conf = RoomConf { name, player_cap: match limit { Some(i) => i, None => usize::MAX }, @@ -141,8 +148,10 @@ async fn tokio_main(conf: Config) -> Result<(), Box> { let new_room = Room { conf: room_conf, players, - driver: handle, + game_driver: game_handle, cmd_stream: cmd_tx, + livepos_driver: livepos_handle, + pos_stream: pos_tx, }; if access.is_some() { pubs.write().await.insert(uid.clone(), serde_json::to_string(&new_room.conf).unwrap()); -- cgit v1.2.3