Skip to content

Commit 95f16b1

Browse files
Merge pull request #4 from Yellow-Dog-Man/prime/logging
feat(logging): add some more logging around recieving and NAT
2 parents faab50e + a868131 commit 95f16b1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

LiteNetLib/NetManager.cs

+3
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,10 @@ private void ProcessConnectRequest(
781781

782782
private void OnMessageReceived(NetPacket packet, IPEndPoint remoteEndPoint)
783783
{
784+
NetDebug.Write($"[NM] Recieved Packet, from:{remoteEndPoint}, it is: {packet.Size} long. Property: {packet.Property}");
784785
if (packet.Size == 0)
785786
{
787+
NetDebug.Write($"[NM] Discarding packet with size 0");
786788
PoolRecycle(packet);
787789
return;
788790
}
@@ -890,6 +892,7 @@ private void DebugMessageReceived(NetPacket packet, IPEndPoint remoteEndPoint)
890892
CreateEvent(NetEvent.EType.ReceiveUnconnected, remoteEndPoint: remoteEndPoint, readerSource: packet);
891893
return;
892894
case PacketProperty.NatMessage:
895+
NetDebug.Write($"[NM] Processing NAT Message from {remoteEndPoint}");
893896
if (NatPunchEnabled)
894897
NatPunchModule.ProcessMessage(remoteEndPoint, packet);
895898
return;

LiteNetLib/NetPeer.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,10 @@ internal NetPeer(NetManager netManager, IPEndPoint remoteEndPoint, int id, byte
400400
_connectRequestPacket.ConnectionNumber = connectNum;
401401

402402
//Send request
403-
NetManager.SendRaw(_connectRequestPacket, this);
403+
var success = NetManager.SendRaw(_connectRequestPacket, this);
404+
404405

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

408409
//"Accept" incoming constructor
@@ -1347,9 +1348,9 @@ internal void Update(int deltaTime)
13471348
return;
13481349
}
13491350

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

0 commit comments

Comments
 (0)