Reducing Network Traffic During Load By reducing use of room properties

Hello. I am working on reducing traffic during the load of our game.

I notice the following code when a player disconnects: (only the master client executes this)

bool isPlayer = (string)otherPlayer.CustomProperties[Strings.PLAYER_TYPE] == "Player" ? true : false;
int playerCount = (int)PhotonNetwork.room.CustomProperties[Strings.PLAYER_COUNT];

int newPlayerCount = isPlayer ? playerCount - 1 : playerCount;
int newSpecCount = !isPlayer ? spectatorCount - 1 : spectatorCount;

ExitGames.Client.Photon.Hashtable roomProperties = new ExitGames.Client.Photon.Hashtable();

roomProperties.Add(Strings.PLAYER_COUNT, newPlayerCount);
roomProperties.Add(Strings.SPECTATOR_COUNT, newSpecCount);

PhotonNetwork.room.SetCustomProperties(roomProperties);

These room properties are set in the game room before we load into our game scene. I don't see these properties used anywhere after we start our game. I just want to double check that it is ok to remove this code.

Comments

  • By mail you told us you are using PUN v1.93. Checking it's code, I can't find "Strings.PLAYER_COUNT" in PUN. So,if you can remove it, depends on your code...

    Overall, the Room class should know the player count and update it.
    Tracking if a player is a spectator or not may be more important. When a player leaves the room, you could simply count "isSpectator" flags in the remaining players' properties, I guess.

    Overall, Photon does not know a concept of spectators, so having this is tricky when it comes to matchmaking. Any player in a room is using a spot. You can't separate player spots into 8 + XY spectators...
  • Thanks for the replay Tobias. Yes I see that this is really a question for our dev team and not photon.