public override void SetUp(UUnitTestContext testContext)
        {
            if (EXEC_ONCE)
            {
                Dictionary <string, string> testInputs;
                string filename = "C:/depot/pf-main/tools/SDKBuildScripts/testTitleData.json"; // TODO: Figure out how to not hard code this
                if (File.Exists(filename))
                {
                    string testInputsFile = PlayFabUtil.ReadAllFileText(filename);

                    testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy);
                }
                else
                {
                    Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults.");
                    testInputs            = new Dictionary <String, String>();
                    testInputs["titleId"] = "6195";
                    testInputs["titleCanUpdateSettings"] = "true";
                    testInputs["userName"]     = "******";
                    testInputs["userEmail"]    = "*****@*****.**";
                    testInputs["userPassword"] = "******";
                }
                SetTitleInfo(testInputs);
                EXEC_ONCE = false;
            }

            if (!TITLE_INFO_SET)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
Exemple #2
0
        // NOTE: If there is an existing catalog with the version number in question, it will be deleted and replaced with only the items specified in this call.
        async public static Task <bool> UpdateCatalogData(string titleId, string catalogVersion, bool isDefault, List <PlayFab.AdminModels.CatalogItem> catalog)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            var result = await PlayFabAdminAPI.SetCatalogItemsAsync(new PlayFab.AdminModels.UpdateCatalogItemsRequest()
            {
                Catalog             = catalog,
                CatalogVersion      = catalogVersion,
                SetAsDefaultCatalog = isDefault
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error));
                return(false);
            }
            return(true);
        }
        public override void SetUp(UUnitTestContext testContext)
        {
            if (_execOnce)
            {
                Dictionary <string, string> testInputs;
                if (File.Exists(TitleDataFilename))
                {
                    var testInputsFile = PlayFabUtil.ReadAllFileText(TitleDataFilename);
                    testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy);
                }
                else
                {
                    // NOTE FOR DEVELOPERS: if you want to run these tests, provide useful defaults, and uncomment this section, or provide a valid path to a "testTitleData.json" file above
                    testInputs = new Dictionary <string, string>();
                    //Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults.");
                    //testInputs["titleId"] = "your title id here";
                    //testInputs["developerSecretKey"] = "your secret key here"; // BE VERY CAREFUL NOT TO PUBLISH THIS, or build it into a client
                }
                SetTitleInfo(testInputs);
                _execOnce = false;
            }

            if (!_titleInfoSet)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
Exemple #4
0
        public static void GetTitleInternalData(string titleID, Action <bool, GetTitleDataResult> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleID);

            PlayFabSettings.TitleId            = titleID;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            var task = PlayFabServerAPI.GetTitleInternalDataAsync(new GetTitleDataRequest()).ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true, result.Result.Result);
                }
            });
        }
Exemple #5
0
        async public static Task <bool> UpdateStoreData(string titleId, string storeId, string catalogVersion, StoreMarketingModel marketingModel, List <PlayFab.AdminModels.StoreItem> store)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            //Console.WriteLine("Updating Store: " + storeId + " on title" + titleId);
            var result = await PlayFabAdminAPI.SetStoreItemsAsync(new PlayFab.AdminModels.UpdateStoreItemsRequest()
            {
                CatalogVersion = catalogVersion,
                StoreId        = storeId,
                MarketingData  = marketingModel,
                Store          = store
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine("Update Store Error: " + PlayFabUtil.GetErrorReport(result.Error));
                return(false);
            }
            return(true);
        }
Exemple #6
0
        async public static Task <bool> UpdateTitleInternalData(string titleId, KeyValuePair <string, string> key)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var result = await PlayFabServerAPI.SetTitleInternalDataAsync(new SetTitleDataRequest()
            {
                Key   = key.Key,
                Value = key.Value
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error));
                return(false);
            }
            return(true);
        }
 public static void Warning(string text, params object[] args)
 {
     if ((PlayFabSettings.LogLevel & PlayFabLogLevel.Warning) != 0)
     {
         UnityEngine.Debug.LogWarning(PlayFabUtil.timeStamp + " WARNING: " + PlayFabUtil.Format(text, args));
     }
 }
Exemple #8
0
 public static void Error(string text, params object[] args)
 {
     if ((PlayFabSettings.LogLevel & PlayFabLogLevel.Error) != PlayFabLogLevel.None)
     {
         UnityEngine.Debug.LogError(PlayFabUtil.timeStamp + " ERROR: " + PlayFabUtil.Format(text, args));
     }
 }
Exemple #9
0
 public static void Debug(string text, params object[] args)
 {
     if ((PlayFabSettings.LogLevel & PlayFabLogLevel.Debug) != PlayFabLogLevel.None)
     {
         UnityEngine.Debug.Log(PlayFabUtil.timeStamp + " DEBUG: " + PlayFabUtil.Format(text, args));
     }
 }
Exemple #10
0
        public static void GetStoreData(string titleId, string storeId, Action <bool, string, string, StoreMarketingModel, List <PlayFab.AdminModels.StoreItem> > callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var task = PlayFabAdminAPI.GetStoreItemsAsync(new PlayFab.AdminModels.GetStoreItemsRequest()
            {
                StoreId = storeId
            })
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine("Get Store Error: " + PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null, null, null, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    var version        = result.Result.Result.CatalogVersion;
                    var marketingModel = result.Result.Result.MarketingData;
                    var currentStoreId = result.Result.Result.StoreId;
                    callback(true, version, currentStoreId, marketingModel, result.Result.Result.Store);
                }
            });
        }
Exemple #11
0
        public static void UpdateStoreData(string titleId, string storeId, string catalogVersion, StoreMarketingModel marketingModel, List <PlayFab.AdminModels.StoreItem> store, Action <bool> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            Console.WriteLine("Updating Store: " + storeId + " on title" + titleId);
            var task = PlayFabAdminAPI.SetStoreItemsAsync(new PlayFab.AdminModels.UpdateStoreItemsRequest()
            {
                CatalogVersion = catalogVersion,
                StoreId        = storeId,
                MarketingData  = marketingModel,
                Store          = store
            })
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine("Update Store Error: " + PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true);
                }
            });
        }
Exemple #12
0
        public static void GetDropTableData(string titleId, Action <bool, Dictionary <string, PlayFab.AdminModels.RandomResultTableListing> > callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var task = PlayFabAdminAPI.GetRandomResultTablesAsync(new PlayFab.AdminModels.GetRandomResultTablesRequest())
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                Task <PlayFabResult <PlayFab.AdminModels.GetRandomResultTablesResult> > taskC = result as Task <PlayFabResult <PlayFab.AdminModels.GetRandomResultTablesResult> >;
                if (taskC.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(taskC.Result.Error));
                    callback(false, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true, taskC.Result.Result.Tables);
                }
            });
        }
Exemple #13
0
        public static void UpdateDropTableData(string titleId, List <RandomResultTable> dropTables, Action <bool> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var task = PlayFabAdminAPI.UpdateRandomResultTablesAsync(new PlayFab.AdminModels.UpdateRandomResultTablesRequest()
            {
                Tables = dropTables
            }
                                                                     )
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true);
                }
            });
        }
Exemple #14
0
        public static void UpdateCatalogData(string titleId, string catalogVersion, bool isDefault, List <PlayFab.AdminModels.CatalogItem> catalog, Action <bool> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            var task = PlayFabAdminAPI.SetCatalogItemsAsync(new PlayFab.AdminModels.UpdateCatalogItemsRequest()
            {
                Catalog             = catalog,
                CatalogVersion      = catalogVersion,
                SetAsDefaultCatalog = isDefault
            })
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true);
                }
            });
        }
Exemple #15
0
        public static void GetContentList(string titleId, Action <bool, List <ContentInfo> > callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var task = PlayFabAdminAPI.GetContentListAsync(new GetContentListRequest())
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true, result.Result.Result.Contents);
                }
            });
        }
Exemple #16
0
        public static void UpdateTitleInternalData(string titleId, KeyValuePair <string, string> key, Action <bool> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var task = PlayFabServerAPI.SetTitleInternalDataAsync(new SetTitleDataRequest()
            {
                Key   = key.Key,
                Value = key.Value
            }).ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true);
                }
            });
        }
Exemple #17
0
        public static void Login(string user, string pass, Action <bool, string> callback)
        {
            var loginTask = PlayFabExtensions.Login(new LoginRequest()
            {
                Email    = user,
                Password = pass,
                DeveloperToolProductName    = "PlayFabPowerTools CLI",
                DeveloperToolProductVersion = "1.01"
            }).ContinueWith((result) =>
            {
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null);
                    return;
                }

                if (result.IsCompleted)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Login Successful");
                    DeveloperClientToken = result.Result.Result.DeveloperClientToken;
                    callback(true, DeveloperClientToken);
                }
            });
        }
Exemple #18
0
        async public static Task <GetStoreItemsResult> GetStoreData(string titleId, string storeId)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var result = await PlayFabAdminAPI.GetStoreItemsAsync(new PlayFab.AdminModels.GetStoreItemsRequest()
            {
                StoreId = storeId
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine("Get Store Error: " + PlayFabUtil.GetErrorReport(result.Error));
                return(null);
            }
            //var version = result.Result.CatalogVersion;
            //var marketingModel = result.Result.MarketingData;
            //var currentStoreId = result.Result.StoreId;

            return(result.Result);
        }
 public static void Info(string text, params object[] args)
 {
     if ((PlayFabSettings.LogLevel & PlayFabLogLevel.Info) != 0)
     {
         UnityEngine.Debug.Log(PlayFabUtil.timeStamp + " INFO: " + PlayFabUtil.Format(text, args));
     }
 }
Exemple #20
0
        public override void SetUp(UUnitTestContext testContext)
        {
            if (EXEC_ONCE)
            {
                Dictionary <string, string> testInputs;
                string filename = "C:/depot/pf-main/tools/SDKBuildScripts/testTitleData.json"; // TODO: Figure out how to not hard code this
                if (File.Exists(filename))
                {
                    string testInputsFile = PlayFabUtil.ReadAllFileText(filename);

                    testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy);
                }
                else
                {
                    // NOTE FOR DEVELOPERS: if you want to run these tests, provide useful defaults, and uncomment this section, or provide a valid path to a "testTitleData.json" file above
                    testInputs = new Dictionary <string, string>();
                    //Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults.");
                    //testInputs["titleId"] = "your title id here";
                    //testInputs["titleCanUpdateSettings"] = "true"; // These tests require a GameManager setting: clients must be able to set stats and userData
                    //testInputs["userName"] = "******";
                    //testInputs["userEmail"] = "*****@*****.**";
                    //testInputs["userPassword"] = "******";
                }
                SetTitleInfo(testInputs);
                EXEC_ONCE = false;
            }

            if (!TITLE_INFO_SET)
            {
                testContext.Skip(); // We cannot do client tests if the titleId is not given
            }
        }
        public static bool ExecuteCloudScript <TIn, TOut>(string functionName, TIn functionParameter, out TOut result, out string errorReport)
        {
            // Perform the request
            var request = new ExecuteCloudScriptRequest
            {
                FunctionName      = functionName,
                FunctionParameter = functionParameter
            };
            var task = PlayFabClientAPI.ExecuteCloudScriptAsync(request);

            task.Wait();
            errorReport = PlayFabUtil.GetErrorReport(task.Result.Error) ?? "";

            if (task.Result.Result != null && task.Result.Result.Error != null)
            {
                errorReport += task.Result.Result.Error.Error + task.Result.Result.Error.Message + "\n" + task.Result.Result.Error.StackTrace;
            }

            if (task.Result.Result != null && task.Result.Result.Logs != null)
            {
                foreach (var eachLog in task.Result.Result.Logs)
                {
                    if (errorReport.Length != 0)
                    {
                        errorReport += "\n";
                    }
                    if (eachLog.Data != null)
                    {
                        // Api failure within cloudscript log
                        string json = JsonConvert.SerializeObject(eachLog.Data, Formatting.Indented);
                        errorReport += eachLog.Level + ": " + eachLog.Message + "\n" + json;
                    }
                    else
                    {
                        // Normal cloudscript log
                        errorReport += eachLog.Level + ": " + eachLog.Message;
                    }
                }
            }

            if (task.Result.Error != null)
            {
                result = default(TOut);
            }
            else
            {
                // Re-serialize as the target type
                string json = JsonConvert.SerializeObject(task.Result.Result.FunctionResult, Formatting.Indented);
                try
                {
                    result = JsonConvert.DeserializeObject <TOut>(json, PlayFabUtil.JsonSettings);
                }
                catch (Exception)
                {
                    throw new Exception("Could not serialize text: \"" + json + "\" as " + typeof(TOut).Name);
                }
            }
            return(task.Result.Error == null && task.Result.Result.Error == null);
        }
Exemple #22
0
        public static TestTitleData LoadTestTitleData(string testTitleDataContents = null, bool setPlayFabSettings = true)
        {
            SetTitleId(setPlayFabSettings);

            if (_loadedData != null)
            {
                return(_loadedData);
            }

            if (!string.IsNullOrEmpty(testTitleDataContents))
            {
                _loadedData = LoadTitleDataWithPlugin(testTitleDataContents);
            }

            if (_loadedData == null)
            {
                var textAsset = Resources.Load <TextAsset>(Path.GetFileNameWithoutExtension(TestTitleDataDefaultFilename));
                if (textAsset != null)
                {
                    _loadedData = LoadTitleDataWithPlugin(textAsset.text);
                }
            }

            if (_loadedData == null)
            {
                var filename = TestTitleDataDefaultFilename;

#if UNITY_STANDALONE_WIN
                // Prefer to load path from environment variable, if present
                var tempFilename = Environment.GetEnvironmentVariable("PF_TEST_TITLE_DATA_JSON");
                if (!string.IsNullOrEmpty(tempFilename))
                {
                    filename = tempFilename;
                }
#endif
                if (File.Exists(filename))
                {
                    testTitleDataContents = PlayFabUtil.ReadAllFileText(filename);
                }

                _loadedData = LoadTitleDataWithPlugin(testTitleDataContents);
            }

            if (_loadedData == null)
            {
                // NOTE FOR DEVELOPERS: POPULATE THIS SECTION WITH REAL INFORMATION (or set up a testTitleData file, and set your PF_TEST_TITLE_DATA_JSON to the path for that file)
                _loadedData = new TestTitleData
                {
                    titleId   = "your title id here",
                    userEmail = "*****@*****.**"
                };
            }

            SetTitleId(setPlayFabSettings);
            return(_loadedData);
        }
Exemple #23
0
 private static void OnAddUsernamePasswordCompleted(Task <PlayFabResult <AddUsernamePasswordResult> > taskResult)
 {
     if (taskResult.Result.Error != null)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Failure calling PlayFab AddUsernamePassword");
         Console.WriteLine(PlayFabUtil.GenerateErrorReport(taskResult.Result.Error));
         Console.ForegroundColor = ConsoleColor.Gray;
     }
 }
Exemple #24
0
 private static void OnAddOrUpdateContactEmailComplete(Task <PlayFabResult <AddOrUpdateContactEmailResult> > taskResult)
 {
     if (taskResult.Result.Error != null)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Failure calling PlayFab AddOrUpdateContactEmail");
         Console.WriteLine(PlayFabUtil.GenerateErrorReport(taskResult.Result.Error));
         Console.ForegroundColor = ConsoleColor.Gray;
     }
 }
Exemple #25
0
 private static void OnUpdateUserDataComplete(Task <PlayFabResult <UpdateUserDataResult> > taskResult)
 {
     if (taskResult.Result.Error != null)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Failure calling PlayFab UpdateUserData");
         Console.WriteLine(PlayFabUtil.GenerateErrorReport(taskResult.Result.Error));
         Console.ForegroundColor = ConsoleColor.Gray;
     }
 }
Exemple #26
0
        private static void OntitlenewsComplete(Task <PlayFabResult <GetTitleNewsResult> > taskResult)
        {
            //Task<PlayFabResult<LoginResult>> task = taskResult;
            Task task = null;

            //TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            //CancellationTokenSource taskCancelSource = new CancellationTokenSource();
            //CancellationToken taskToken = taskCancelSource.Token;
            task = Task.Factory.StartNew(() =>
            {
                PlayFabSettings.TitleId = "850C";

                var apiError  = taskResult.Result.Error;
                var apiResult = taskResult.Result.Result;
                Console.WriteLine("HELLO" + apiError);
                var apiErrorCode = PlayFabUtil.GetErrorReport(apiError);
                Console.WriteLine("3");
                if (apiError != null)
                {
                    //Console.ForegroundColor = ConsoleColor.Red; // Make the error more visible
                    //Console.WriteLine("Something went wrong with your first API call.  :(");
                    MessageBox.Show("Something went wrong with your first API call.  :(");
                    //Console.WriteLine("Here's some debug information:");
                    Console.WriteLine(PlayFabUtil.GetErrorReport(apiError));
                    //Console.ForegroundColor = ConsoleColor.Gray; // Reset to normal
                    Console.WriteLine("4");
                }
                else if (apiResult != null)
                {
                    //  Console.WriteLine("Congratulations, you made your first successful API call!");
                    //MessageBox.Show("" + apiResult.News);
                    foreach (var news in apiResult.News)
                    {
                        Console.WriteLine(news.Body);
                        MessageBox.Show("" + news.Body);
                    }
                }
            });


            //    }, CancellationToken.None, TaskCreationOptions.None, uiScheduler);



            //taskResult = Task<PlayFabResult<LoginResult>>.WaitAll();
            //                    Task.WaitAll(new[] { taskResult});

            Console.WriteLine("6");
        }
Exemple #27
0
 private static void OnLoginComplete(Task <PlayFabResult <LoginResult> > taskResult)
 {
     if (taskResult.Result.Error != null)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Failure calling PlayFab Authentication");
         Console.WriteLine(PlayFabUtil.GenerateErrorReport(taskResult.Result.Error));
         Console.ForegroundColor = ConsoleColor.Gray;
     }
     else
     if (taskResult.Result.Result != null)
     {
         Console.WriteLine("Congratulations, you made your first successful API call!");
         _loginSuccessful = true;
     }
 }
Exemple #28
0
    private void OnLoginComplete(PlayFabResult <LoginResult> taskResult)
    {
        var apiError = taskResult.Error;

        if (apiError != null)
        {
            Console.ForegroundColor = ConsoleColor.Red;  // Make the error more visible
            Console.WriteLine(PlayFabUtil.GenerateErrorReport(apiError));
            Console.ForegroundColor = ConsoleColor.Gray; // Reset to normal
        }
        else
        {
            IsConnected = true;
        }
        _running = false;
    }
Exemple #29
0
        private void OnLoginComplete(PlayFabResult <LoginResult> taskResult)
        {
            var apiError  = taskResult.Error;
            var apiResult = taskResult.Result;

            if (apiError != null)
            {
                Console.ForegroundColor = ConsoleColor.Red; // Make the error more visible
                Console.WriteLine("Something went wrong with your first API call.  :(");
                Console.WriteLine("Here's some debug information:");
                Console.WriteLine(PlayFabUtil.GenerateErrorReport(apiError));
                Console.ForegroundColor = ConsoleColor.Gray; // Reset to normal
            }
            else if (apiResult != null)
            {
                Console.WriteLine("Congratulations, you made your first successful API call!");
            }
        }
        public static TestTitleData LoadTestTitleData(string testTitleDataContents = null, bool setPlayFabSettings = true)
        {
            SetTitleId(setPlayFabSettings);

            if (_loadedData != null)
            {
                return(_loadedData);
            }

            if (testTitleDataContents == null)
            {
                var filename = TestTitleDataDefaultFilename;

#if UNITY_STANDALONE_WIN
                // Prefer to load path from environment variable, if present
                var tempFilename = Environment.GetEnvironmentVariable("PF_TEST_TITLE_DATA_JSON");
                if (!string.IsNullOrEmpty(tempFilename))
                {
                    filename = tempFilename;
                }
#endif
                if (File.Exists(filename))
                {
                    testTitleDataContents = PlayFabUtil.ReadAllFileText(filename);
                }
            }

            if (!string.IsNullOrEmpty(testTitleDataContents))
            {
                _loadedData = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <TestTitleData>(testTitleDataContents);
            }
            else
            {
                // NOTE FOR DEVELOPERS: POPULATE THIS SECTION WITH REAL INFORMATION (or set up a testTitleData file, and set your PF_TEST_TITLE_DATA_JSON to the path for that file)
                _loadedData = new TestTitleData
                {
                    titleId   = "your title id here",
                    userEmail = "*****@*****.**"
                };
            }

            SetTitleId(setPlayFabSettings);
            return(_loadedData);
        }