示例#1
0
        public static void GetCatalogData(string titleId, Action <bool, string, List <PlayFab.AdminModels.CatalogItem> > callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var task = PlayFabAdminAPI.GetCatalogItemsAsync(new PlayFab.AdminModels.GetCatalogItemsRequest())
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false, null, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    var version = result.Result.Result.Catalog[0].CatalogVersion;
                    callback(true, version, result.Result.Result.Catalog);
                }
            });
        }
示例#2
0
        public async Task <List <PlayFabItem> > GetStoreItems()
        {
            var isCacheUpdated = await IsCacheUpdated();

            if (!cache.TryGetValue(CacheKeys.Store, out List <PlayFabItem> items) || !isCacheUpdated)
            {
                var reqGetCatalog = new GetCatalogItemsRequest
                {
                    CatalogVersion = configuration.CatalogName,
                };

                var reqGetStore = new GetStoreItemsRequest
                {
                    CatalogVersion = configuration.CatalogName,
                    StoreId        = configuration.StoreName
                };

                var resultCatalog = await PlayFabAdminAPI.GetCatalogItemsAsync(reqGetCatalog);

                if (resultCatalog.Error != null)
                {
                    throw new Exception(resultCatalog.Error.ErrorMessage);
                }

                var resultStore = await PlayFabAdminAPI.GetStoreItemsAsync(reqGetStore);

                if (resultStore.Error != null)
                {
                    throw new Exception(resultStore.Error.ErrorMessage);
                }

                var catalog = resultCatalog.Result.Catalog;
                var store   = resultStore.Result.Store;

                items = MergeAndGetItemList(catalog, store);
                cache.Set(CacheKeys.Store, items, cacheEntryOptions);
                if (!isCacheUpdated)
                {
                    await UpdateStoreVersionCache();
                }
            }

            return(items);
        }
示例#3
0
        // Currently onle fetches the default catalog
        async public static Task <List <PlayFab.AdminModels.CatalogItem> > GetCatalogData(string titleId)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

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

            var result = await PlayFabAdminAPI.GetCatalogItemsAsync(new PlayFab.AdminModels.GetCatalogItemsRequest());

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error));
                return(null);
            }
            //var version = result.Result.Catalog[0].CatalogVersion;
            return(result.Result.Catalog);
        }