UNET - Kick player

Hi!

I’ve been digging for around 3 hours now, I cant seem to find a proper way to kick players from the server.

I’ve tried all combinations of these

        NetworkServer.DestroyPlayersForConnection(player.connectionToServer);
        player.connectionToClient.Disconnect();
        player.connectionToClient.Dispose();
        player.connectionToServer.Disconnect();
        player.connectionToServer.Dispose();

but this does not seem to do the trick, and only causes exceptions in the NetworkServer down the line.

Could someone please share the proper way to do so? (because the docs on unet are hopelessly outdated)

The way I usually do this is through a call to the player objects network identity. Eg:

PlayerObject.GetComponent<NetworkIdentity> ().connectionToClient.Disconnect ();