remove and add logging
This commit is contained in:
parent
bd581ae317
commit
4f75b3c156
|
@ -116,7 +116,7 @@ async fn udp_server(socket: Arc<UdpSocket>) {
|
||||||
loop {
|
loop {
|
||||||
let mut packet = [0u8; 256];
|
let mut packet = [0u8; 256];
|
||||||
let (size, _addr) = socket.recv_from(&mut packet).await.unwrap();
|
let (size, _addr) = socket.recv_from(&mut packet).await.unwrap();
|
||||||
tracing::trace!("got packet from {_addr:?}");
|
// tracing::trace!("got packet from {_addr:?}");
|
||||||
match read_packet(&mut Cursor::new(&mut packet[..size]), true).await {
|
match read_packet(&mut Cursor::new(&mut packet[..size]), true).await {
|
||||||
Ok(packet) => {
|
Ok(packet) => {
|
||||||
// info!("packet from udp {packet:?}");
|
// info!("packet from udp {packet:?}");
|
||||||
|
|
|
@ -109,7 +109,7 @@ impl PlayerActor {
|
||||||
tokio::spawn(scoped(&address.downgrade(), {
|
tokio::spawn(scoped(&address.downgrade(), {
|
||||||
let address = address.downgrade();
|
let address = address.downgrade();
|
||||||
async move {
|
async move {
|
||||||
// sending packets to the web app or setting up udp
|
// sending packets to the game or setting up udp
|
||||||
let ip = addr.ip();
|
let ip = addr.ip();
|
||||||
let mut addr = None;
|
let mut addr = None;
|
||||||
while let Some(message) = receiver.recv().await {
|
while let Some(message) = receiver.recv().await {
|
||||||
|
@ -142,7 +142,7 @@ impl PlayerActor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WriteMessage::SetUdp(port) => {
|
WriteMessage::SetUdp(port) => {
|
||||||
trace!("now connected on udp!");
|
trace!("now connected on udp at {}", SocketAddr::new(ip, port));
|
||||||
addr = Some(SocketAddr::new(ip, port));
|
addr = Some(SocketAddr::new(ip, port));
|
||||||
|
|
||||||
let mut buf = [0; 256];
|
let mut buf = [0; 256];
|
||||||
|
@ -258,11 +258,6 @@ impl Handler<Packet> for PlayerActor {
|
||||||
PacketData::UdpInit(UdpInit { port }) => {
|
PacketData::UdpInit(UdpInit { port }) => {
|
||||||
info!("got udp init {port}!");
|
info!("got udp init {port}!");
|
||||||
let _ = self.write_sender.send(WriteMessage::SetUdp(port));
|
let _ = self.write_sender.send(WriteMessage::SetUdp(port));
|
||||||
let _ = self.write_sender.send(WriteMessage::Data(Packet {
|
|
||||||
user_id: self.id,
|
|
||||||
udp: true,
|
|
||||||
data: PacketData::HolePunch(HolePunch),
|
|
||||||
}));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PacketData::Connect(..) | PacketData::Init(..) => {
|
PacketData::Connect(..) | PacketData::Init(..) => {
|
||||||
|
|
|
@ -46,6 +46,7 @@ impl ProximityPlayer {
|
||||||
let state = manager.send(RequestState).await.unwrap();
|
let state = manager.send(RequestState).await.unwrap();
|
||||||
|
|
||||||
send.write_u8(state.len() as u8).await.expect("failed to write length");
|
send.write_u8(state.len() as u8).await.expect("failed to write length");
|
||||||
|
trace!("sending player count: {}", state.len());
|
||||||
for player in state.values() {
|
for player in state.values() {
|
||||||
trace!(parent: &span, "sending player {player:?}");
|
trace!(parent: &span, "sending player {player:?}");
|
||||||
send.write_all(player.as_bytes()).await.expect("failed to write player");
|
send.write_all(player.as_bytes()).await.expect("failed to write player");
|
||||||
|
|
Loading…
Reference in a new issue