Skip to content

Commit

Permalink
Merge pull request #2 from Yellow-Dog-Man/prime/logging
Browse files Browse the repository at this point in the history
Connection request logging
  • Loading branch information
ProbablePrime authored Apr 23, 2024
2 parents c1a05a4 + ab90522 commit fb8c269
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions LiteNetLib/NetPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ internal NetPeer(NetManager netManager, IPEndPoint remoteEndPoint, int id, byte
//Send request
NetManager.SendRaw(_connectRequestPacket, this);

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

//"Accept" incoming constructor
Expand All @@ -422,7 +422,7 @@ internal NetPeer(NetManager netManager, ConnectionRequest request, int id)
//Send
NetManager.SendRaw(_connectAcceptPacket, this);

NetDebug.Write(NetLogLevel.Trace, $"[CC] ConnectId: {_connectTime}");
NetDebug.Write(NetLogLevel.Trace, $"[CC] ConnectId: {_connectTime}, Endpoint: {request.RemoteEndPoint}");
}

//Reject
Expand Down Expand Up @@ -1342,10 +1342,12 @@ internal void Update(int deltaTime)
_connectAttempts++;
if (_connectAttempts > NetManager.MaxConnectAttempts)
{
NetDebug.Write($"[Update] Connected ID: {_connectTime} failed to respond to a connection request after {_connectAttempts} attempts.");
NetManager.DisconnectPeerForce(this, DisconnectReason.ConnectionFailed, 0, null);
return;
}

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

0 comments on commit fb8c269

Please sign in to comment.