aboutsummaryrefslogtreecommitdiff
path: root/src/wire
diff options
context:
space:
mode:
Diffstat (limited to 'src/wire')
-rw-r--r--src/wire/mod.rs23
-rw-r--r--src/wire/resp.rs17
2 files changed, 16 insertions, 24 deletions
diff --git a/src/wire/mod.rs b/src/wire/mod.rs
index bf8dea0e8131..b1c231b44580 100644
--- a/src/wire/mod.rs
+++ b/src/wire/mod.rs
@@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize};
pub type UserId = usize;
/// Represents a user payload
-#[derive(Clone, Serialize, Deserialize)]
+#[derive(Copy, Clone, Serialize, Deserialize)]
pub struct User {
/// The internal user ID
pub id: UserId,
@@ -34,7 +34,7 @@ pub struct User {
}
/// A more lobby specific abstraction for a user
-#[derive(Serialize, Deserialize)]
+#[derive(Clone, Serialize, Deserialize)]
pub struct LobbyUser {
/// The user ID
pub id: UserId,
@@ -42,6 +42,8 @@ pub struct LobbyUser {
pub name: String,
/// Are they ready?
pub ready: bool,
+ /// Are they the lobby admin?
+ pub admin: bool,
/// The colour they will be in the match
pub color: Color,
}
@@ -50,7 +52,7 @@ pub struct LobbyUser {
pub type LobbyId = usize;
/// Represent a lobby
-#[derive(Serialize, Deserialize)]
+#[derive(Clone, Serialize, Deserialize)]
pub struct Lobby {
/// The ID of the lobby
pub id: LobbyId,
@@ -65,19 +67,4 @@ pub struct Lobby {
/// An alias for a match ID
pub type MatchId = usize;
-/// Mapping users to a player in game
-#[derive(Serialize, Deserialize)]
-pub struct MatchUser {
- pub user: User,
- pub player: Player,
-}
-#[derive(Serialize, Deserialize)]
-pub struct Match {
- /// The match id
- pub id: MatchId,
- /// The list of active players
- pub players: Vec<MatchUser>,
- /// The active game map
- pub map: Map,
-}
diff --git a/src/wire/resp.rs b/src/wire/resp.rs
index b9f41fbe93e4..4812baf13e39 100644
--- a/src/wire/resp.rs
+++ b/src/wire/resp.rs
@@ -16,18 +16,17 @@ pub enum Response {
/// Get a list of available <name-room> pairs
Rooms(Vec<(String, LobbyId)>),
/// A user joins a game lobby
- Join(Result<Lobby, RoomErr>),
+ Join(Result<Lobby, LobbyErr>),
/// A user leaves a game lobby
- Leave(Result<(), RoomErr>),
+ Leave(Result<(), LobbyErr>),
/// Get the new set of ready states
- Ready(RoomUpdate),
+ Ready(LobbyUpdate),
/// Receiving a start request time
StartReq(DateTime<Utc>),
/// Response to the action with the state update
GameUpdate(UpdateState),
/// Leave the match (forfeit)
LeaveGame(Result<(), MatchErr>),
-
}
#[derive(Serialize, Deserialize)]
@@ -53,17 +52,23 @@ pub enum AuthErr {
}
#[derive(Serialize, Deserialize)]
-pub enum RoomErr {
+pub enum LobbyErr {
/// The requested room is already full
RoomFull,
/// The room id is unknown
NoSuchRoom,
/// Previously not in room
NotInRoom,
+ /// Not everybody was ready
+ NotAllReady,
+ /// A request was sent by someone who isn't authorised
+ NotAuthorized,
+ /// Other internal error, try again?
+ OtherError,
}
#[derive(Serialize, Deserialize)]
-pub enum RoomUpdate {
+pub enum LobbyUpdate {
/// The set of ready users
Ready(Vec<UserId>),
}