How to use best region in Photon Realtime Javascript SDK

According to https://doc.photonengine.com/zh-tw/realtime/current/connection-and-authentication/regions#best_region_selection there is a way to select best region in Photon Realtime (at least for C#). But how to do the same thing in javascript? I am unable to find example code anywhere or even info on if this is even possible with the Javascript SDK.

In the docs (https://doc-api.photonengine.com/en/javascript/current/Photon.LoadBalancing.LoadBalancingClient.html) there is only connectToRegionMaster() function that takes the region to connect as parameter explicitly.

I am creating a browser based game for world wide audience and it is important to auto-select the region with the lowest ping. How do I achieve this? Do I have to somehow manually ping all the region masters?

Comments

  • Also interested.... Mine seems to try to connect to the EU no matter what.
  • Could someone from the mods (maybe @vadim ?) provide an answer please?
  • vadim
    vadim mod
    edited November 2020
    JS Photon client does not support automatic best region detection.
    You need to implement this yourself by connecting to each region master server and measuring response time to a command, for example requestLobbyStats. Make sure that automatic lobby stats update is disabled in connect() call options,