use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::Arc;
use tokio::sync::mpsc::Sender;
use tokio::sync::RwLock;
#[derive(Clone)]
pub struct ClientManager {
pub handlers: Arc<RwLock<HashMap<SocketAddr, ClientHandler>>>,
pub usernames: Arc<RwLock<HashMap<SocketAddr, String>>>,
pub players: Arc<RwLock<HashMap<SocketAddr, Player>>>
}
#[derive(Default)]
pub struct Player {
pub id: u16,
pub x: f64,
pub y: f64,
pub vel_x: f64,
pub vel_y: f64,
}
#[derive(Clone)]
pub struct ClientHandler {
pub tx: Sender<ClientHandlerMessage>
}
pub enum ClientHandlerMessage {
Tick,
ChatMessage { from: String, message: String }
}