How to get list Region which player online joined?

Options
Hi.I'm having a problems.If 2 player with 2 different region then they can't connect with together.I'm using JoinRandomRoom.My solution when player connect to region which don't have any player online joined then I want switch that player to region exits(which other player created).Now I want to know all region that player joined.or which have other solution? Sorry my English.Thanks.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Amobear,

    Thank you for choosing Photon!

    You can make use of "App Stats" to know how many players are connected.
    To get the list of regions in PUN2, implement IConnectionCallbacks.OnRegionListReceived(RegionHandler).
  • Amobear
    Options
    I use IConnectionCallbacks and override OnRegionListReceived(RegionHandler) but this method don't call.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2019
    Options
    Hi @Amobear,

    Make sure to register the callbacks implemented by calling PhotonNetwork.AddCallbackTarget(this).
    Read ".Net Callbacks".
    Or simply extend MonoBehaviourPunCallbacks.
    If you enable "SupportLogger" from PhotonServerSettings for debugging purposes, you can check if OnRegionListReceived is really called or not.

    If you have a "Fixed Region" in PhotonServerSettings, the callback will not be triggered as the client will try to connect to that specific fixed region instead of fetching the list of available regions from the server. If you do not call ConnectUsingSettings, the callback may not be triggered.
  • Amobear
    Amobear
    edited May 2019
    Options
    I created a class:
    public class RegionMode : MonoBehaviourPunCallbacks
    {
    
        // Use this for initialization
        void Start() {
            PhotonNetwork.ConnectUsingSettings();
        }
    
        public override void OnRegionListReceived(RegionHandler regionHandler)
        {
            base.OnRegionListReceived(regionHandler);
            Debug.Log("REGION " + regionHandler.EnabledRegions.ToString());
        }
    } 
    and attack it to scene but this method still don't call.Where am I wrong? Thanks.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2019
    Options
    Hi @Amobear,

    What do you have in your "Fixed Region" field under "App Settings" inside PhotonServerSettings?
    It should be left empty or blank.

    Assuming you are connecting to Photon Cloud of course and not self-hosted Photon Server.
  • Amobear
    Options
    Thanks @JohnTube .I remove fixed region in photonserversetting.Right now i'ts showed all list region.But Which I really want to know.Assuming when I connect to best region is "asia" but don't have anyone in "asia" server.Asssuming having other player in "eu" server.Which I need when I check don't have anyone same my server and then I find server that player joined and switch to that server.thanks.