use game::Game; pub type SessionToken = [u8; 8]; pub type SessionSecret = [u8; 8]; pub struct Player { pub user:Option, pub connections:Vec, } pub struct Session { pub id:u32, pub token:SessionToken, pub secret:SessionSecret, pub game:Game, pub p_dawn:Player, pub p_dusk:Player, pub connections:Vec, pub time:u64, pub chain_id:usize, } impl Session { pub fn get_connections(&self) -> Vec { [ self.p_dawn.connections.clone(), self.p_dusk.connections.clone(), self.connections.clone(), ].concat() } pub fn remove_connection(&mut self, source:u8, id:u32) { let connections = match source { 0 => &mut self.p_dawn.connections, 1 => &mut self.p_dusk.connections, _ => &mut self.connections, }; for i in 0..connections.len() { if connections[i] == id { connections.remove(i); break; } } } }