PhotonNetwork.CloseConnection C# (CSharp) Method

CloseConnection() public static method

Request a client to disconnect (KICK). Only the master client can do this.
public static CloseConnection ( PhotonPlayer, kickPlayer ) : void
kickPlayer PhotonPlayer, The PhotonPlayer to kick.
return void
    public static void CloseConnection(PhotonPlayer kickPlayer)
    {
        if (!VerifyCanUseNetwork())
        {
            return;
        }

        if (!player.isMasterClient)
        {
            Debug.LogError("CloseConnection: Only the masterclient can kick another player.");
        }

        if (kickPlayer == null)
        {
            Debug.LogError("CloseConnection: No such player connected!");
        }
        else
        {
            int[] rec = new int[1];
            rec[0] = kickPlayer.ID;
            networkingPeer.OpRaiseEvent(PhotonNetworkMessages.CloseConnection, null, true, 0, rec);
        }
    }

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// Kicks the given PhotonPlayer from the room he is in.
 /// </summary>
 public void KickPlayer(PhotonPlayer player)
 {
     if (PhotonNetwork.isMasterClient && PhotonNetwork.inRoom)
     {
         PhotonNetwork.CloseConnection(player);
     }
 }
All Usage Examples Of PhotonNetwork::CloseConnection