I’m trying to implement a function to Kick a player out of the Server, but upon adding this function to a button event:
NetworkManager.Singleton.DisconnectClient(1, "Kicked by LobbyHost.");
It kicks BOTH the Client with ID 1 and the Host with ID 0.
Logs For Client Disconnect:
Disconnected Client ID: 1
UnityEngine.Debug:Log (object)
AbstractLobbyManager/<>c:<Start>b__14_0 (ulong) (at Assets/Scripts/UI/AbstractLobbyManager.cs:72)
Unity.Netcode.NetworkConnectionManager:InvokeOnClientDisconnectCallback (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs:140)
Unity.Netcode.NetworkConnectionManager:OnClientDisconnectFromServer (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs:1028)
Unity.Netcode.NetworkConnectionManager:DisconnectRemoteClient (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs:1055)
Unity.Netcode.NetworkConnectionManager:DisconnectClient (ulong,string) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs:1085)
Unity.Netcode.NetworkManager:DisconnectClient (ulong,string) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:1140)
AbstractStandardLobbyManager/<>c:<ListPlayers>b__6_1 () (at Assets/Scripts/UI/AbstractStandardLobbyManager.cs:236)
UnityEngine.EventSystems.EventSystem:Update () (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/EventSystem/EventSystem.cs:530)
Logs For Host Disconnect which happens after the Client Disconnects above:
Disconnected Client ID: 0
UnityEngine.Debug:Log (object)
AbstractLobbyManager/<>c:<Start>b__14_0 (ulong) (at Assets/Scripts/UI/AbstractLobbyManager.cs:72)
Unity.Netcode.NetworkConnectionManager:InvokeOnClientDisconnectCallback (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs:140)
Unity.Netcode.NetworkConnectionManager:DisconnectEventHandler (ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs:502)
Unity.Netcode.NetworkConnectionManager:HandleNetworkEvent (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment`1<byte>,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs:396)
Unity.Netcode.NetworkConnectionManager:PollAndHandleNetworkEvents () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs:370)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:44)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:192)
Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:215)
All my code is calling is that Disconnect function, any idea why it is also Disconnecting the Server/Host?