SetApp() публичный Метод

public SetApp ( string appId, string gameVersion ) : void
appId string
gameVersion string
Результат void
Пример #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));
 }
Пример #2
0
    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());
    }
Пример #3
0
    public static bool ConnectToMaster(string masterServerAddress, int port, string appID, string gameVersion)
    {
        //PhotonNetwork.SwitchToProtocol((ExitGames.Client.Photon.ConnectionProtocol) PlayerPrefs.GetInt("TCPProtocol", (int)ExitGames.Client.Photon.ConnectionProtocol.WebSocket));

        if (networkingPeer.PeerState != PeerStateValue.Disconnected)
        {
            Debug.LogWarning("ConnectToMaster() failed. Can only connect while in state 'Disconnected'. Current state: " + networkingPeer.PeerState);
            return(false);
        }
        if (offlineMode)
        {
            offlineMode = false;
            Debug.LogWarning("ConnectToMaster() disabled the offline mode. No longer offline.");
        }
        if (!isMessageQueueRunning)
        {
            isMessageQueueRunning = true;
            Debug.LogWarning("ConnectToMaster() enabled isMessageQueueRunning. Needs to be able to dispatch incoming messages.");
        }
        networkingPeer.SetApp(appID, gameVersion);
        networkingPeer.IsUsingNameServer   = false;
        networkingPeer.IsInitialConnect    = true;
        networkingPeer.MasterServerAddress = masterServerAddress + ":" + port;
        return(networkingPeer.Connect(networkingPeer.MasterServerAddress, ServerConnection.MasterServer));
    }