/// <summary>
        /// Extracts the Ip address that should be used to connect via the receptionist. The order is as follows:
        /// 1. Try to extract the ip address from command line arguments passed in. This currently only works for Android.
        /// 2. If we are running on an Android Emulator: Use the Ip address necessary to connect locally.
        /// 3. If we are on a physical device (Android & iOS): Try to extract the value from the stored player preferences.
        /// 4. Check if we stored anything inside the IpAddress field and use it, if we have.
        /// 5. Return the default ReceptionistHost (localhost).
        /// </summary>
        /// <returns>Returns the Host IP.</returns>
        protected virtual string GetHostIp()
        {
            var arguments = LaunchArguments.GetArguments();
            var hostIp    =
                CommandLineUtility.GetCommandLineValue(arguments, RuntimeConfigNames.ReceptionistHost, string.Empty);

            if (!string.IsNullOrEmpty(hostIp))
            {
                return(hostIp);
            }

            if (Application.isMobilePlatform)
            {
                switch (DeviceInfo.ActiveDeviceType)
                {
                case MobileDeviceType.Virtual:
#if UNITY_ANDROID
                    return(DeviceInfo.AndroidEmulatorDefaultCallbackIp);
#else
                    break;
#endif
                case MobileDeviceType.Physical:
                    return(PlayerPrefs.GetString(HostIpPlayerPrefsKey, IpAddress));
                }
            }

            if (!string.IsNullOrEmpty(IpAddress))
            {
                return(IpAddress);
            }

            return(RuntimeConfigDefaults.ReceptionistHost);
        }
        protected virtual void InitializeClient()
        {
            var arguments   = LaunchArguments.GetArguments();
            var environment = CommandLineUtility.GetCommandLineValue(arguments, RuntimeConfigNames.Environment, string.Empty);

            if (string.IsNullOrEmpty(environment))
            {
                environment = PlayerPrefs.GetString(RuntimeConfigNames.Environment, string.Empty);
            }
            else
            {
                PlayerPrefs.SetString(RuntimeConfigNames.Environment, environment);
            }

            if (!string.IsNullOrEmpty(environment))
            {
                ShouldConnectLocally = environment == RuntimeConfigDefaults.LocalEnvironment;
            }

            if (ShouldConnectLocally)
            {
                IpAddress = GetHostIp();
                PlayerPrefs.SetString(HostIpPlayerPrefsKey, IpAddress);
            }
            else
            {
                PlayerPrefs.DeleteKey(HostIpPlayerPrefsKey);
            }

            PlayerPrefs.Save();
        }
Exemplo n.º 3
0
            public Option <string> GetDevAuthToken()
            {
                var args = LaunchArguments.GetArguments();

                var devAuthToken = string.Empty;

                if (!args.TryGetCommandLineValue(RuntimeConfigNames.DevAuthTokenKey, ref devAuthToken))
                {
                    return(Option <string> .Empty);
                }

                PlayerPrefs.SetString(RuntimeConfigNames.DevAuthTokenKey, devAuthToken);
                PlayerPrefs.Save();
                return(devAuthToken);
            }
Exemplo n.º 4
0
            public Option <string> GetReceptionistHostIp()
            {
                var args = LaunchArguments.GetArguments();

                var hostIp = string.Empty;

                if (!args.TryGetCommandLineValue(RuntimeConfigNames.ReceptionistHost, ref hostIp))
                {
                    return(Option <string> .Empty);
                }

                PlayerPrefs.SetString(RuntimeConfigNames.ReceptionistHost, hostIp);
                PlayerPrefs.Save();
                return(hostIp);
            }
Exemplo n.º 5
0
            public Option <ConnectionService> GetConnectionService()
            {
                var args = LaunchArguments.GetArguments();

                var environment = string.Empty;

                if (!args.TryGetCommandLineValue(RuntimeConfigNames.Environment, ref environment))
                {
                    return(Option <ConnectionService> .Empty);
                }

                PlayerPrefs.SetString(RuntimeConfigNames.Environment, environment);
                PlayerPrefs.Save();

                return(environment == RuntimeConfigDefaults.LocalEnvironment
                    ? ConnectionService.Receptionist
                    : ConnectionService.Locator);
            }