From 7d954e22f6c5370fe120c7a1f712488f4063a073 Mon Sep 17 00:00:00 2001 From: Aubrey Taylor Date: Mon, 23 Dec 2024 04:41:41 -0600 Subject: [PATCH] send hole punch directly after storing address --- src/player.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/player.rs b/src/player.rs index 50ed000..e3b7b24 100644 --- a/src/player.rs +++ b/src/player.rs @@ -142,7 +142,12 @@ impl PlayerActor { } WriteMessage::SetUdp(port) => { trace!("now connected on udp!"); - addr = Some(SocketAddr::new(ip, port)) + addr = Some(SocketAddr::new(ip, port)); + + let mut buf = [0; 256]; + let mut writer = Cursor::new(buf.as_mut_slice()); + write_packet(&mut writer, user_id, PacketData::HolePunch(HolePunch)).await.unwrap(); + socket.send_to(&buf, addr.as_ref().unwrap()).await.expect("kys"); } } }