Ejemplo n.º 1
0
        /// <summary>
        /// This initializes the GameObject and ensures it is in the scene.
        /// </summary>
        public static void InitializeHttp()
        {
            if (_internalHttp != null)
            {
                return;
            }

            Application.runInBackground = true; // Http requests respond even if you lose focus
#if !UNITY_WSA && !UNITY_WP8
            if (PlayFabSettings.RequestType == WebRequestType.HttpWebRequest)
            {
                _internalHttp = new PlayFabWebRequest();
            }
#endif
            if (_internalHttp == null)
            {
                _internalHttp = new PlayFabWww();
            }

#if ENABLE_PLAYFABADMIN_API || ENABLE_PLAYFABSERVER_API
            _internalHttp.DevKey = PlayFabSettings.DeveloperSecretKey;
#endif
            _internalHttp.InitializeHttp();
            CreateInstance(); // Invoke the SingletonMonoBehaviour
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This initializes the GameObject and ensures it is in the scene.
        /// </summary>
        public static void InitializeHttp()
        {
            if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
            {
                throw new PlayFabException(PlayFabExceptionCode.TitleNotSet, "You must set PlayFabSettings.TitleId before making API Calls.");
            }
            if (_internalHttp != null)
            {
                return;
            }

            Application.runInBackground = true; // Http requests respond even if you lose focus
#if !UNITY_WSA && !UNITY_WP8
            if (PlayFabSettings.RequestType == WebRequestType.HttpWebRequest)
            {
                _internalHttp = new PlayFabWebRequest();
            }
#endif
#if UNITY_2017_2_OR_NEWER
            if (PlayFabSettings.RequestType == WebRequestType.UnityWebRequest)
            {
                _internalHttp = new PlayFabUnityHttp();
            }
#endif
            if (_internalHttp == null)
            {
                _internalHttp = new PlayFabWww();
            }

            _internalHttp.InitializeHttp();
            CreateInstance(); // Invoke the SingletonMonoBehaviour
        }
        /// <summary>
        /// This initializes the GameObject and ensures it is in the scene.
        /// </summary>
        public static void InitializeHttp()
        {
            if (_internalHttp != null)
            {
                return;
            }

            Application.runInBackground = true; // Http requests respond even if you lose focus
#if !UNITY_WSA && !UNITY_WP8
            if (PlayFabSettings.RequestType == WebRequestType.HttpWebRequest)
            {
                _internalHttp = new PlayFabWebRequest();
            }
#endif
#if UNITY_2017_2_OR_NEWER
            if (PlayFabSettings.RequestType == WebRequestType.UnityWebRequest)
            {
                _internalHttp = new PlayFabUnityHttp();
            }
#endif
            if (_internalHttp == null)
            {
                _internalHttp = new PlayFabWww();
            }

            _internalHttp.InitializeHttp();
            CreateInstance(); // Invoke the SingletonMonoBehaviour
        }
Ejemplo n.º 4
0
        static PlayFabHttp()
        {
            var httpInterfaceType = typeof(IPlayFabHttp);
            var types             = typeof(PlayFabHttp).GetAssembly().GetTypes();

            foreach (var eachType in types)
            {
                if (httpInterfaceType.IsAssignableFrom(eachType) && !eachType.IsAbstract)
                {
                    _http = (IPlayFabHttp)Activator.CreateInstance(eachType.AsType());
                    return;
                }
            }
            throw new Exception("Cannot find a valid IPlayFabHttp type");
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Optional redirect to allow mocking of _internalHttp calls, or use a custom _internalHttp utility
 /// </summary>
 public static void SetHttp <THttpObject>(THttpObject httpObj) where THttpObject : IPlayFabHttp
 {
     _internalHttp = httpObj;
 }