diff options
author | Katharina Fey <kookie@spacekookie.de> | 2021-02-14 00:06:14 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2021-02-14 00:06:14 +0100 |
commit | effbdeed66e8de8e769b8ac069926ad1a9110e62 (patch) | |
tree | e4522354e53266204aa9962caccde55d8c815092 /games/rstnode/rst-core/src/_match.rs | |
parent | 5dab336049dbc6817e9ff212998690f59f6bbfa8 (diff) |
* Add an inbox/ outbox system to server components
* Define a data flow from Request -> computation -> Update
* Create simple handlers to call server or client code for requests
Diffstat (limited to 'games/rstnode/rst-core/src/_match.rs')
-rw-r--r-- | games/rstnode/rst-core/src/_match.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/games/rstnode/rst-core/src/_match.rs b/games/rstnode/rst-core/src/_match.rs index ce75af5af393..e1cc45374ebc 100644 --- a/games/rstnode/rst-core/src/_match.rs +++ b/games/rstnode/rst-core/src/_match.rs @@ -1,8 +1,9 @@ use crate::{ data::Player, lobby::MetaLobby, + mailbox::{Inbox, Outbox}, map::Map, - wire::{Action, LobbyUser, MatchId, UserId}, + wire::{game::Action, LobbyUser, MatchId, UserId}, }; use async_std::sync::{Arc, RwLock}; use chrono::{DateTime, Utc}; @@ -23,7 +24,9 @@ pub struct Match { /// The active game map pub map: Map, /// Input inbox (handled in-order each game tick) - inbox: RwLock<VecDeque<Action>>, + inbox: Inbox, + /// Update outbox + outbox: Outbox, /// The time the match was initialised init_t: DateTime<Utc>, /// The synced time the match was started @@ -46,7 +49,8 @@ impl From<MetaLobby> for Match { }) .collect(), map: Map::new(), - inbox: Default::default(), + inbox: Inbox::new(), + outbox: Outbox::new(), init_t: Utc::now(), start_t: None, } @@ -61,7 +65,7 @@ impl Match { /// Queue a new game action pub async fn queue(&self, cmd: Action) { - self.inbox.write().await.push_back(cmd); + self.inbox.queue(cmd).await; } pub async fn handle_inbox(&mut self) { |