App and Lobby Stats
Photon servers can broadcast application and lobby statistics to clients. You can make use of this data to enhance your client-driven matchmaking. You can also brag about these statistics in your game to show how popular it is. :]
Application Statistics
While connected to a Master Server, clients receive application statistics for the current region.
The applications statistics are available via the RealtimeClient / LoadBalancingClient:
Number of live rooms:
loadBalancingClient.RoomsCountNumber of players not joined to rooms:
loadBalancingClient.PlayersOnMasterCountNumber of players inside rooms:
loadBalancingClient.PlayersInRoomsCountTotal number of connected players:
loadBalancingClient.PlayersOnMasterCount + loadBalancingClient.PlayersInRoomsCount
An AppStats event is sent to clients every five seconds.
Lobby Statistics
Lobby statistics can be useful if a game uses multiple lobbies and you want to show the activity.
Per typed lobby (name + type) you can get information about:
- Number of live rooms
- Total number of players joined to the lobby or joined to the lobby's rooms
Lobby stats only include lobbies in the current Virtual App (App ID plus App Version) and region.
Automatically Get Lobby Statistics
Lobby statistics events are sent as soon as the client is authenticated to a master server. Then they are sent every minute. Lobby statistics events are disabled by default but can be enabled.
Enable lobby statistics by setting loadBalancingClient.EnableLobbyStatistics = true; before connecting.
Get the statistics from the ILobbyCallbacks.OnLobbyStatisticsUpdate callback which could be useful to update your UI.
Photon Server Configuration
You can configure how often LobbyStats event is sent to clients. To do so, change the value of "LobbyStatsPublishInterval" inside the configuration file of the Photon master server application. The unit used is seconds.
XML
<Photon.LoadBalancing.MasterServer.MasterServerSettings>
<setting name="LobbyStatsPublishInterval" serializeAs="String">
<value>120</value>
</setting>
</Photon.LoadBalancing.MasterServer.MasterServerSettings>
There is also an optional setting to limit the number of statistics returned by the server. To do so, change the value of "LobbyStatsLimit" inside the configuration file of the Photon master server application. If not configured or set to zero no limit will by applied. Any other positive integer will set the maximum allowed number of lobbies.
XML
<Photon.LoadBalancing.MasterServer.MasterServerSettings>
<setting name="LobbyStatsLimit" serializeAs="String">
<value>0</value>
</setting>
</Photon.LoadBalancing.MasterServer.MasterServerSettings>
Back to top