aboutsummaryrefslogtreecommitdiff
path: root/games/rstnode/rst-core/src/server.rs
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2021-02-19 00:12:38 +0100
committerKatharina Fey <kookie@spacekookie.de>2021-02-19 00:12:38 +0100
commit2f401b176b343cf881f3ac3397ffc66808128950 (patch)
tree6d824dc6ea89329e7e3bb54db8b31d11c0428c5a /games/rstnode/rst-core/src/server.rs
parent837a0ca6438d1f78a7364c3c7c310dc96e01f31d (diff)
rstnode: add basic map i/o mechanism for server and client
Diffstat (limited to 'games/rstnode/rst-core/src/server.rs')
-rw-r--r--games/rstnode/rst-core/src/server.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/games/rstnode/rst-core/src/server.rs b/games/rstnode/rst-core/src/server.rs
index 68fa2a074e34..a550a8396395 100644
--- a/games/rstnode/rst-core/src/server.rs
+++ b/games/rstnode/rst-core/src/server.rs
@@ -12,7 +12,7 @@ use crate::{
game::Action, AuthErr, Lobby, LobbyErr, LobbyId, LobbyUpdate, MatchErr, MatchId, RegErr,
Response, UpdateState, User, UserId,
},
- GameIf, Match,
+ GameIf, Lock, LockMap, Match,
};
use async_std::sync::{Arc, Mutex};
use async_trait::async_trait;
@@ -32,7 +32,7 @@ pub enum ServerErr {
/// The game's server backend
pub struct Server {
- matches: BTreeMap<MatchId, Mutex<Match>>,
+ matches: LockMap<MatchId, Lock<Match>>,
users: UserStore,
lobbies: LobbyList,
}
@@ -81,8 +81,8 @@ impl Server {
where
F: Fn(&mut Vec<Player>) -> ServerResult<Response>,
{
- match self.matches.get(&id) {
- Some(ref mut m) => cb(&mut m.lock().await.players),
+ match self.matches.read().await.get(&id) {
+ Some(ref mut m) => cb(&mut m.write().await.players),
None => Err(ServerErr::NoSuchMatch),
}
}