border-wars/crates/server/src/lib.rs

39 lines
709 B
Rust
Raw Normal View History

2024-04-12 02:36:23 +00:00
use std::collections::HashMap;
2024-04-12 02:36:23 +00:00
use serde::{Deserialize, Serialize};
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-12 02:36:23 +00:00
#[derive(Serialize, Deserialize)]
pub enum ServerPacket {
Refused(String),
LobbyJoined(Uuid),
LobbyUpdated(Lobby),
}
2024-04-12 02:36:23 +00:00
#[derive(Serialize, Deserialize)]
pub struct Lobby {
pub public: bool,
pub players: HashMap<Uuid, LobbyPlayer>,
}
2024-04-12 02:36:23 +00:00
#[derive(Serialize, Deserialize)]
pub struct LobbyPlayer {
pub username: String,
pub ready: bool,
}