Correct Procedure to Immediately Kick a Player (Server-side) in UNET

Hi guys,

I’m currently attempting to solve some issues we’re having when multiple players all attempt to join into the last slot on the server at the same time.

I’m using a custom NetworkManager, and would like to be able to kick players during OnServerAddPlayer(NetworkConnection conn, short playerControllerId).

At this point, doing:

conn.Disconnect();

sort-of works, but generates errors on the server which are probably breaking some other things I’ve not noticed yet (my previous experience with any UNET errors).

What is the correct procedure to disconnect a player at this point? I don’t care about sending them a message detailing why they’ve been disconnected.

Thanks in advance for any help.

2 Likes

To clarify the following is the error I get when the client is kicked:

Failed to send internal buffer channel:0 bytesToSend:547
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

The channel is 0 because they haven’t finished connecting yet. Is it a bug that UNET is trying to send stuff on this channel and hasn’t picked up that they’ve failed to connect? The same thing happens if a 4th player tries to join a game capped at 3 players.

2 Likes