Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

Discussion in 'UNet' started by Morgenstern_1, Jun 15, 2016.

  1. Morgenstern_1

    Morgenstern_1

    Joined:
    Jul 1, 2013
    Posts:
    34
    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.
     
    LPerry and Leoo like this.
  2. Morgenstern_1

    Morgenstern_1

    Joined:
    Jul 1, 2013
    Posts:
    34
    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.
     
    MohammadAlizadeh and Leoo like this.