kubi/kubi-server/src/client.rs

21 lines
555 B
Rust
Raw Normal View History

2023-03-12 19:56:33 -05:00
use shipyard::{Component, EntityId, Unique, AllStoragesView};
use hashbrown::HashMap;
2023-03-08 20:30:37 -06:00
use std::net::SocketAddr;
pub use kubi_shared::networking::client::ClientIdMap;
2023-02-11 17:37:24 -06:00
2023-03-08 20:30:37 -06:00
#[derive(Component, Clone, Copy)]
pub struct ClientAddress(pub SocketAddr);
2023-03-08 20:30:37 -06:00
#[derive(Unique, Default)]
pub struct ClientAddressMap(pub HashMap<SocketAddr, EntityId>);
impl ClientAddressMap {
pub fn new() -> Self { Self::default() }
}
pub fn init_client_maps(
storages: AllStoragesView
) {
storages.add_unique(ClientIdMap::new());
storages.add_unique(ClientAddressMap::new());
}