Fix: Resolve an exception in the server when reaching Max Players in server mode

This commit is contained in:
Karrar
2025-08-14 00:42:46 +03:00
parent 7b0669ed1a
commit 0843f02c15
8 changed files with 7 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -100,7 +100,7 @@ namespace Netick.Transport
void INetEventListener.OnConnectionRequest(ConnectionRequest request)
{
if (_clients.Count >= Engine.Config.MaxPlayers)
if (_freeClients.Count == 0)
{
request.Reject();
return;
@@ -118,6 +118,11 @@ namespace Netick.Transport
void INetEventListener.OnPeerConnected(NetPeer peer)
{
if (_freeClients.Count == 0)
{
peer.Disconnect();
return;
}
var connection = _freeClients.Dequeue();
connection.LNLPeer = peer;
_clients. Add(peer, connection);

View File

@@ -1,6 +1,6 @@
{
"name": "com.karrar.netick",
"version": "0.14.60",
"version": "0.14.61",
"displayName": "Netick",
"description": "A networking solution for Unity",
"unity": "2021.3",