Skip to content

Commit

Permalink
Merge pull request #4 from Yellow-Dog-Man/prime/logging
Browse files Browse the repository at this point in the history
feat(logging): add some more logging around recieving and NAT
  • Loading branch information
ProbablePrime authored May 4, 2024
2 parents faab50e + a868131 commit 95f16b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions LiteNetLib/NetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,10 @@ private void ProcessConnectRequest(

private void OnMessageReceived(NetPacket packet, IPEndPoint remoteEndPoint)
{
NetDebug.Write($"[NM] Recieved Packet, from:{remoteEndPoint}, it is: {packet.Size} long. Property: {packet.Property}");
if (packet.Size == 0)
{
NetDebug.Write($"[NM] Discarding packet with size 0");
PoolRecycle(packet);
return;
}
Expand Down Expand Up @@ -890,6 +892,7 @@ private void DebugMessageReceived(NetPacket packet, IPEndPoint remoteEndPoint)
CreateEvent(NetEvent.EType.ReceiveUnconnected, remoteEndPoint: remoteEndPoint, readerSource: packet);
return;
case PacketProperty.NatMessage:
NetDebug.Write($"[NM] Processing NAT Message from {remoteEndPoint}");
if (NatPunchEnabled)
NatPunchModule.ProcessMessage(remoteEndPoint, packet);
return;
Expand Down
9 changes: 5 additions & 4 deletions LiteNetLib/NetPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,10 @@ internal NetPeer(NetManager netManager, IPEndPoint remoteEndPoint, int id, byte
_connectRequestPacket.ConnectionNumber = connectNum;

//Send request
NetManager.SendRaw(_connectRequestPacket, this);
var success = NetManager.SendRaw(_connectRequestPacket, this);


NetDebug.Write(NetLogLevel.Trace, $"[CC] ConnectId: {_connectTime}, ConnectNum: {connectNum}, Endpoint: {remoteEndPoint}");
NetDebug.Write(NetLogLevel.Trace, $"[CC] ConnectId: {_connectTime}, ConnectNum: {connectNum}, Endpoint: {remoteEndPoint}, ConnectRequestSuccess: {success}");
}

//"Accept" incoming constructor
Expand Down Expand Up @@ -1347,9 +1348,9 @@ internal void Update(int deltaTime)
return;
}

NetDebug.Write($"[Update] Connected ID: {_connectTime} Sending another connection request, this is attempt {_connectAttempts}.");
//else send connect again
NetManager.SendRaw(_connectRequestPacket, this);
var success = NetManager.SendRaw(_connectRequestPacket, this);
NetDebug.Write($"[Update] Connected ID: {_connectTime} Sending another connection request, this is attempt {_connectAttempts}. Send result: {success}");
}
return;

Expand Down

0 comments on commit 95f16b1

Please sign in to comment.