From d0bb4a2c2636862f44d174edb7e809593ce27c62 Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Mon, 29 Jan 2024 17:52:06 +0100 Subject: use wrapping client ids --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index f06948c..9c2490b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use std::fs; use std::io; use std::net::SocketAddr; +use std::num::Wrapping; use std::sync::Arc; use tokio::sync::{mpsc, Mutex}; @@ -68,10 +69,12 @@ impl PacketCodec for NullCodec { } } +type HandleId = (Wrapping, ChannelId); + #[derive(Clone)] struct Server { - clients: Arc>>, - id: usize, + clients: Arc>>, + id: Wrapping, packets: Arc>>>, } @@ -235,7 +238,7 @@ async fn main() -> Result<()> { let server = Server { clients: Arc::new(Mutex::new(HashMap::new())), - id: 0, + id: Wrapping(0), packets: Arc::new(Mutex::new(HeapRb::new(64000))), }; -- cgit v1.2.3