Why does a Dedicated Server return +1 values for num players/max players?

Options
Wobbles67
Wobbles67
edited May 2022 in Fusion

When I get the session info from a dedicated server it returns values of + 1. For instance, if I create a dedicated server session with max players 20...

    var result = await runner.StartGame(new StartGameArgs()
    {
      GameMode = GameMode.Server,
      SessionName = "MyServer",
      PlayerCount = 20,
      Scene = SceneManager.GetSceneByName(sceneToLoad).buildIndex,
      SceneObjectProvider = gameObject.AddComponent<NetworkSceneManagerDefault>()
    });

...when my client retrieves the session list before joining it shows max players as 21 with 1 player already joined even though no players have joined yet.

    public void OnSessionListUpdated(NetworkRunner runner, List<SessionInfo> sessionList) 
    {
      SetConnectionStatus(ConnectionStatus.InLobby);

      foreach(SessionInfo info in sessionList)
      {
        Debug.Log($"Server = {info.Name}, NumPlayers = {info.PlayerCount}, MaxPlayers = {info.MaxPlayers}");
      }
    }

Output is: Server = MyServer, NumPlayers = 1, MaxPlayers = 21

Am I missing a setting or is this standard behaviour?

Answers

  • ramonmelo
    Options

    Hi @Wobbles67 ,


    Any and every peer connected to the Photon Cloud counts towards the CCU, so a Dedicated Server would not be different. As you've set it up to accept at most 20 clients, it needs an extra slot for the Server itself, hence why you get the extra slot from the Session.

    MaxPlayers is related to the number of peers connected to the Photon Cloud Room, not to the number of actual players connected to your dedicated server.

    In the case of running Fusion in Host mode, there is no need for the extra slot, as the Host would accept only 19 more players, leading to 20 in total. This is not true for the Dedicated Server, as it does not contains any local player.

    You are not missing anything, it is just how it works internally to accommodate all the clients you want to be able to accept + the server in the Session.


    --

    Ramon Melo

    Photon Fusion Team

  • Wobbles67
    Options

    Ah okay. That makes sense, and it's good the dedicated server doesn't take one of your slots. I've just adjusted the values returned from the session by subtracting 1 so that players logging don't see incorrect numbers.