ConnectToRegionMaster() public method

Connects you to a specific region's Master Server, using the Name Server to find the IP.
public ConnectToRegionMaster ( CloudRegionCode region ) : bool
region CloudRegionCode
return bool
Beispiel #1
0
 public static bool ConnectUsingSettings(string gameVersion)
 {
     if (PhotonServerSettings == null)
     {
         Debug.LogError("Can't connect: Loading settings failed. ServerSettings asset must be in any 'Resources' folder as: PhotonServerSettings");
         return(false);
     }
     SwitchToProtocol(PhotonServerSettings.Protocol);
     networkingPeer.SetApp(PhotonServerSettings.AppID, gameVersion);
     if (PhotonServerSettings.HostType == ServerSettings.HostingOption.OfflineMode)
     {
         offlineMode = true;
         return(true);
     }
     if (offlineMode)
     {
         Debug.LogWarning("ConnectUsingSettings() disabled the offline mode. No longer offline.");
     }
     offlineMode                     = false;
     isMessageQueueRunning           = true;
     networkingPeer.IsInitialConnect = true;
     if (PhotonServerSettings.HostType == ServerSettings.HostingOption.SelfHosted)
     {
         networkingPeer.IsUsingNameServer   = false;
         networkingPeer.MasterServerAddress = PhotonServerSettings.ServerAddress + ":" + PhotonServerSettings.ServerPort;
         return(networkingPeer.Connect(networkingPeer.MasterServerAddress, ServerConnection.MasterServer));
     }
     if (PhotonServerSettings.HostType == ServerSettings.HostingOption.BestRegion)
     {
         return(ConnectToBestCloudServer(gameVersion));
     }
     return(networkingPeer.ConnectToRegionMaster(PhotonServerSettings.PreferredRegion));
 }
    public static bool ConnectToBestCloudServer(string gameVersion)
    {
        if (PhotonServerSettings == null)
        {
            Debug.LogError("Can't connect: Loading settings failed. ServerSettings asset must be in any 'Resources' folder as: PhotonServerSettings");
            return(false);
        }

        if (PhotonServerSettings.HostType == ServerSettings.HostingOption.OfflineMode)
        {
            return(ConnectUsingSettings(gameVersion));
        }

        networkingPeer.IsInitialConnect = true;
        networkingPeer.SetApp(PhotonServerSettings.AppID, gameVersion);
        var bestRegionCodeInPreferences = PhotonHandler.BestRegionCodeInPreferences;

        if (bestRegionCodeInPreferences != CloudRegionCode.none)
        {
            Debug.Log("Best region found in PlayerPrefs. Connecting to: " + bestRegionCodeInPreferences);
            return(networkingPeer.ConnectToRegionMaster(bestRegionCodeInPreferences));
        }

        return(networkingPeer.ConnectToNameServer());
    }