diff options
author | Lizzy Fleckenstein <eliasfleckenstein@web.de> | 2023-01-05 14:55:57 +0100 |
---|---|---|
committer | Lizzy Fleckenstein <eliasfleckenstein@web.de> | 2023-01-05 15:14:34 +0100 |
commit | d3b8019227137853406891e2aa84e0c8a9e3c31c (patch) | |
tree | 26d61ff87212fb6c476a3ad60cd27104d257f692 /src/main.rs | |
parent | b011620dbb4243d4a0d9febb89e438a2dd517a61 (diff) | |
download | mt_rudp-d3b8019227137853406891e2aa84e0c8a9e3c31c.tar.xz |
send acks
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index b6a6af6..1f0aca0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use std::{ ops, sync::Arc, }; -use tokio::sync::{mpsc, Mutex, RwLock}; +use tokio::sync::{mpsc, watch, Mutex, RwLock}; pub const PROTO_ID: u32 = 0x4f457403; pub const UDP_PKT_SIZE: usize = 512; @@ -69,12 +69,13 @@ pub struct Pkt<T> { pub type Error = error::Error; pub type InPkt = Result<Pkt<Vec<u8>>, Error>; +type AckChan = (watch::Sender<bool>, watch::Receiver<bool>); #[derive(Debug)] pub struct RudpShare<S: UdpSender> { pub id: u16, pub remote_id: RwLock<u16>, - pub ack_chans: Mutex<HashMap<u16, mpsc::Sender<()>>>, + pub ack_chans: Mutex<HashMap<u16, AckChan>>, udp_tx: S, } @@ -203,5 +204,7 @@ async fn main() -> io::Result<()> { } println!("disco"); + // close()ing rx is not needed because it has been consumed to the end + Ok(()) } |