2024-04-12 02:36:23 +00:00
|
|
|
use std::collections::HashMap;
|
2024-04-08 17:53:21 +00:00
|
|
|
|
2024-04-12 02:36:23 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2024-04-08 17:53:21 +00:00
|
|
|
use uuid::Uuid;
|
|
|
|
|
2024-04-12 02:36:23 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub enum ClientPacket {
|
|
|
|
Disconnect,
|
|
|
|
CreateLobby {
|
|
|
|
username: String,
|
|
|
|
public: bool,
|
|
|
|
},
|
|
|
|
JoinLobby {
|
|
|
|
lobby_id: Option<Uuid>,
|
|
|
|
username: String,
|
|
|
|
},
|
|
|
|
IAmReady,
|
|
|
|
IAmNotReady,
|
2024-04-08 17:53:21 +00:00
|
|
|
}
|
|
|
|
|
2024-04-12 02:36:23 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub enum ServerPacket {
|
|
|
|
Refused(String),
|
|
|
|
LobbyJoined(Uuid),
|
|
|
|
LobbyUpdated(Lobby),
|
2024-04-10 21:29:53 +00:00
|
|
|
}
|
2024-04-08 17:53:21 +00:00
|
|
|
|
2024-04-12 02:36:23 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct Lobby {
|
|
|
|
pub public: bool,
|
|
|
|
pub players: HashMap<Uuid, LobbyPlayer>,
|
2024-04-08 17:53:21 +00:00
|
|
|
}
|
|
|
|
|
2024-04-12 02:36:23 +00:00
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
pub struct LobbyPlayer {
|
|
|
|
pub username: String,
|
|
|
|
pub ready: bool,
|
2024-04-08 17:53:21 +00:00
|
|
|
}
|