Can't get ping for all regions
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Can't get ping for all regions
Insthync
2020-09-14 05:21:55
I've override OnRegionListReceived
from MonoBehaviourPunCallbacks
class, I can get all regions but almost all of them wasn't pinged. Only the best region I've connected was pinged. Whats I can do to get all regions ping?
Comments
Can you try like this?
public override void OnRegionListReceived(RegionHandler regionHandler)
{
regionHandler.PingMinimumOfRegions(PingCompleteCallback, "");
}
void PingCompleteCallback(RegionHandler regionHandler)
{
//Ping result about to all regions
List<Photon.Realtime.Region> regions = regionHandler.EnabledRegions;
foreach (var region in regions)
{
Debug.Log(region.Ping);
}
//Region with lowest ping
Debug.Log(regionHandler.BestRegion.Code + " " + regionHandler.BestRegion.Ping);
}
This callback probably returning best ping result.
Yes, I've try it, as I said I was override OnRegionListReceived
function but when get ping from regions each ping value is int.MaxValue except the best region.
I can fix ping problem by ServerSettings.ResetBestRegionCodeInPreferences()
before connect to best cloud server.
About best cloud server connection, when connecting to best cloud server, it will connect to name server.
Then when connect to name server it will pinging all regions
If PUNCloudBestRegion
not existed, if it's existed it will not ping all regions.
Hi @Insthync,
Why do you need/want to ping ALL regions (every time)?
Maybe there is a misunderstanding of how best region works and how it's determined.
Read more here.
Players might want to play with other players from difference regions, and they may want to see other region's ping to decide to connect. It's does not have to ping everytime, just once when start a game is okay. Only way to get regions list is to connect to best cloud region, but when connect to best cloud region, only best cloud region is pingged maybe because it was stored in reference when ServerSettings.ResetBestRegionCodeInPreferences()
it will re-ping all regions.