summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 11 insertions, 2 deletions
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<dyn Error>> {
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<dyn Error>> {
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());