OnLobbyStatisticsUpdate not updating when a new player joins Master

Options
I'm using this bit of code below to grab the current player count for the server. It seems it only updates once when I join the server rather then when someone else does. Is this the correct way to be doing this? I essentially want to grabbing the player count for the server about once every 5 to 10 seconds to display to the player.
public override void OnLobbyStatisticsUpdate() { 
    PlayerCount = PhotonNetwork.countOfPlayers.ToString(); 
}
Thanks in advance!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited November 2017
    Options
    Hi @meatloaf,

    Thank you for choosing Photon!

    As read in this doc page:

    AppStats event is sent [to client] every five seconds.

    Is this the correct way to be doing this?
    Yes, the first AppStats event is received as soon as the client is connected to Master Server. Then every 5 seconds.
  • meatloaf
    Options
    Thanks so much for the response. It doesn't seem to be updating every 5 seconds though.

    I connect to master on one client and get a +1 to player count. Connecting another player to master though doesn't seem to +1 player count for the original joiner.

    I have stats enabled as well. Just not sure what the problem is.

    Thanks!
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Maybe players are on different servers (different region) or different virtual applications (different AppId or different AppVersion).
  • meatloaf
    Options
    Interestingly I have checked all of those settings and they match across the board. I'm really curious what could be going on here.
  • meatloaf
    meatloaf
    edited November 2017
    Options
    After some investigation it looks like this does seem to work, but the update time is definitely not 5 seconds on my end. It looks more to be about a minute or so.

    Is there any way to change this update time?

    --Edit--

    After some searching it looks like this I was right in my assumption that it was about a minute. After searching for "AppStats event is sent [to client] every five seconds." on google I was able to find the link below.

    App & Lobby Stats

    An excerpt states
    Lobby statistics events are sent as soon as the client is authenticated to a master server then they are sent every minute.


    Still curious if there is a way to change this update time?

    Thanks in advance!
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @meatloaf,

    There are two events:

    AppStats: sent every 5 seconds
    LobbyStats: sent every minute

    You can't change the frequency on Photon Cloud.
    You can change this on self-hosted Photon Server or maybe Photon Enterprise Cloud (not sure about the latter).

    In any case, I will double check with the team and maybe run few tests for the 5 seconds period.
  • KapilKhatik
    Options

    Hello, I want to get the player count or room count of the different SQL typed lobby I have Separately, But I'm struggling to implement this. "lobbyStatistics[].PlayerCount" this is where I'm getting player count or room count option in "OnLobbyStatisticsUpdate(List<TypedLobbyInfo> lobbyStatistics)" callback function. But I'm not getting how to pass the reference of a particular lobby inside of "[]" this curly braces, or I'm trying to implement this wrong and there's some other method? Kindly help. I have been struggling to get this for weeks. Any help will be appriciated.


    Below attaching the ss of what I want to achieve. Thanks in advance


  • Tobias
    Options

    The lobbyStatistics is a List or array. To find a particular lobby (likely by name), you have to iterate through the list and check each name.

    I don't think that the list order is guaranteed (lobbies may be added), so you should update the index after getting new stats.