Inheritance: PlayFabRequestCommon
Example #1
0
    public void GetTitleInternalData()
    {
        datasLoaded = false;
        var getRequest = new PlayFab.ServerModels.GetTitleDataRequest();

        PlayFabServerAPI.GetTitleData(getRequest, (result) => {
            foreach (var entry in result.Data)
            {
                if (string.Compare(entry.Key, "Achievements") == 0)
                {
                    //Debug.Log("Got the following titleData:");
                    //Debug.Log(entry.Key + ": " + entry.Value);
                    datas       = entry.Key + entry.Value;
                    datasLoaded = true;
                }
                else
                {
                    Debug.Log("No achievements in database");
                }
            }
        },
                                      (error) => {
            Debug.Log("Got error getting titleData:");
            Debug.Log(error.ErrorMessage);
        });
    }
Example #2
0
        public static void LoadFromPlayfab(Rect position)
        {
            string datas;
            var    getRequest = new PlayFab.ServerModels.GetTitleDataRequest();

            PlayFabServerAPI.GetTitleData(getRequest, (result) => {
                bool isLoadingOk = false;
                foreach (var entry in result.Data)
                {
                    if (string.Compare(entry.Key, "Achievements") == 0)
                    {
                        isLoadingOk = true;
                        datas       = entry.Value;
                        LoadFromJson(datas);
                    }
                    else
                    {
                        Debug.Log("No achievements in database");
                    }
                }
                if (isLoadingOk)
                {
                    newPopUp(position, "Datas Succesfully loaded from PlayFab");
                }
            },
                                          (error) => {
                Debug.Log("Got error getting titleData:");
                Debug.Log(error.ErrorMessage);
            });
        }
Example #3
0
		/// <summary>
		/// Retrieves the key-value store of custom internal title settings
		/// </summary>
		public static void GetTitleInternalData(GetTitleDataRequest request, GetTitleInternalDataCallback resultCallback, ErrorCallback errorCallback)
		{
			if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");

			string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings);
			Action<string,string> callback = delegate(string responseStr, string errorStr)
			{
				GetTitleDataResult result = null;
				PlayFabError error = null;
				ResultContainer<GetTitleDataResult>.HandleResults(responseStr, errorStr, out result, out error);
				if(error != null && errorCallback != null)
				{
					errorCallback(error);
				}
				if(result != null)
				{
					
					if(resultCallback != null)
					{
						resultCallback(result);
					}
				}
			};
			PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Server/GetTitleInternalData", serializedJSON, "X-SecretKey", PlayFabSettings.DeveloperSecretKey, callback);
		}
Example #4
0
		/// <summary>
		/// Retrieves the key-value store of custom internal title settings
		/// </summary>
        public static async Task<PlayFabResult<GetTitleDataResult>> GetTitleInternalDataAsync(GetTitleDataRequest request)
        {
            if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");

            object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Server/GetTitleInternalData", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
            if(httpResult is PlayFabError)
            {
                PlayFabError error = (PlayFabError)httpResult;
                if (PlayFabSettings.GlobalErrorHandler != null)
                    PlayFabSettings.GlobalErrorHandler(error);
                return new PlayFabResult<GetTitleDataResult>
                {
                    Error = error,
                };
            }
            string resultRawJson = (string)httpResult;

            var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings);
            var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetTitleDataResult>>(new JsonTextReader(new StringReader(resultRawJson)));
			
			GetTitleDataResult result = resultData.data;
			
			
            return new PlayFabResult<GetTitleDataResult>
                {
                    Result = result
                };
        }