send hole punch directly after storing address

This commit is contained in:
Aubrey 2024-12-23 04:41:41 -06:00
parent 869f8d04c7
commit 7d954e22f6
No known key found for this signature in database

View file

@ -142,7 +142,12 @@ impl PlayerActor {
} }
WriteMessage::SetUdp(port) => { WriteMessage::SetUdp(port) => {
trace!("now connected on udp!"); 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");
} }
} }
} }