Inheritance: PlayFabRequestCommon
示例#1
0
    protected IEnumerator userDataQuerry(GetUserDataRequest request)
    {
        wait = true;

        PlayFabClientAPI.GetUserData(request, (result) => {
            Debug.Log("Got user data:");
            if ((result.Data == null) || (result.Data.Count == 0))
            {
                Debug.Log("No user data available");
            }
            else
            {
                succesfullUserDataQuerry(result);
            }
            querrySuccesfull = true;
            wait = false;
        }, (error) => {
            failedUserDataQuerry(error);
            this.error = error;
            querrySuccesfull = false;
            wait = false;
        });

        while (wait)
        { yield return null; }
    }
示例#2
0
    void GetUserData()
    {
        GetUserDataRequest request = new GetUserDataRequest() {
            PlayFabId = PlayFabId,
            Keys = null
        };

        PlayFabClientAPI.GetUserData(request,(result) => {
            Debug.Log("Got user data:");
            if ((result.Data == null) || (result.Data.Count == 0)) {
                Debug.Log("No user data available");
            }
            else {
        //				foreach (var item in result.Data) {
        //					Debug.Log("    " + item.Key + " == " + item.Value.Value);
        //				}
        //
        //				Debug.Log("    " + result.Data["win"].Value);
                player_name = result.Data["name"].Value;
            }
        }, (error) => {
            Debug.Log("Got error retrieving user data:");
            Debug.Log(error.ErrorMessage);
        });
    }
 ///GetUserData()
 /// <summary>
 /// Retrieves UserData from PlayFab.
 /// </summary>
 /// Pre-Condition: Must be signed into a PlayFab account.
 /// Post-Condition: The Data from the PlayFab account will be retrieved.
 public static void GetUserData()
 {
     if (_playFabId == null)
         return;
     //PlayFab API call requires a request to retrieve data.
     var GetUserDataRequest = new PlayFab.ClientModels.GetUserDataRequest(){ PlayFabId = _playFabId };
     //PlayFab API call to retrieve data from the PlayFab account.
     PlayFabClientAPI.GetUserData(GetUserDataRequest,
         (result) =>
         {
             Debug.Log(_playFabId + "GetUserDataRequest");
             foreach (var entry in result.Data)
             {
                 Debug.Log(entry.Key + ": " + entry.Value.Value);
                 //This will be used for Clear Data.
                 _Key.Add(entry.Key);
             }
             DataResult.Invoke(result);
         },
         (error) =>
         {
             Debug.Log(_playFabId);
             Debug.Log("Error: GetUserData()");
             Debug.Log(error.ErrorMessage);
         }
     );
 }
示例#4
0
    public override IEnumerator makeQuerry()
    {
        GetUserDataRequest request = new GetUserDataRequest()
        { Keys = new List<string>() { "DeckList" } };

        yield return userDataQuerry(request);
    }
示例#5
0
    /// <summary>
    /// 사용자의 정보 불러오기
    /// </summary>
    public void Getdata(string myId)
    {
        //myId 를 이용해서 플레이팹에서 나의 정보를 불러올수 있다.
        var request = new PlayFab.ClientModels.GetUserDataRequest()
        {
            PlayFabId = myId
        };

        PlayFabClientAPI.GetUserData(request, OnGetdataSuccess, OnGetdataFail);
    }
    public void Populate(PlayerLeaderboardEntry myInfo)
    {
        positionTxt.text = (myInfo.Position + 1).ToString();
        nameTxt.text = myInfo.DisplayName;
        killsTxt.text = myInfo.StatValue + " kills";

        GetUserDataRequest request = new GetUserDataRequest();

        request.PlayFabId = myInfo.PlayFabId;
        request.Keys = new List<string>();
        request.Keys.Add(GameConstants.facebookPictureKey);

        PlayFabClientAPI.GetUserData(request, OnPlayerInfoLoaded, OnPlayerInfoLoadError);
    }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_dataKeys"></param>
        /// <param name="_playerDataResult"></param>
        /// <param name="_playerDataResultError"></param>
        public static void GetPlayerReadOnlyData(List <string> _dataKeys, Action <PlayFab.ClientModels.GetUserDataResult> _playerDataResult, Action _playerDataResultError = null)
        {
            var request = new PlayFab.ClientModels.GetUserDataRequest
            {
                Keys = _dataKeys
            };

            PlayFabClientAPI.GetUserReadOnlyData(request, _playerDataResult,
                                                 _OnError =>
            {
                if (_playerDataResultError != null)
                {
                    _playerDataResultError();
                }
            });
        }
示例#8
0
    public override IEnumerator makeQuerry()
    {
        GetUserDataRequest request = new GetUserDataRequest()
        {
            Keys = new List<string>()
            {
                "UserName",
                "Currency",
                "IsPremium",
                "PremiumCredit",
                "StoreDeckNameList",
                "DeckList"
            }
        };

        yield return userDataQuerry(request);
    }
    public override void Setup()
    {
        base.Setup();
        this.OnEvent<LoginPlayfabUser>().Subscribe(_ =>
        {
            PlayFabClientAPI.LoginWithPlayFab(new LoginWithPlayFabRequest()
            {
                TitleId = Title_Id,
                Username = _.Username,
                Password = _.Password
            },result =>
            {
                GetUserDataRequest request = new GetUserDataRequest()
                {

                };
                PlayFabClientAPI.GetUserData(request, userDataResult =>
                {
                    Data = userDataResult.Data;
                }, null, null);

            },null);
        });
    }
        /// <summary>
        /// Retrieves the title-specific custom data for the user which can only be read by the client
        /// </summary>
        public static void GetUserReadOnlyData(GetUserDataRequest request, ProcessApiCallback<GetUserDataResult> resultCallback, ErrorCallback errorCallback, object customData = null)
        {
            if (_authKey == null) throw new Exception("Must be logged in to call this method");

            string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy);
            Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer)
            {
                ResultContainer<GetUserDataResult>.HandleResults(requestContainer, resultCallback, errorCallback, null);
            };
            PlayFabHTTP.Post("/Client/GetUserReadOnlyData", serializedJson, "X-Authorization", _authKey, callback, request, customData);
        }
		public void Start() {
			GetUserDataRequest request = new GetUserDataRequest ();
			if (PlayFabData.AuthKey != null)
				PlayFabClientAPI.GetUserData (request, LoadPlayerData, OnPlayFabError);
			InvokeRepeating("SavePlayerState", 10, 10);
		}
示例#12
0
        public void UserDataApi()
        {
            int testCounterValueExpected, testCounterValueActual;

            var getRequest = new GetUserDataRequest();
            PlayFabClientAPI.GetUserData(getRequest, GetUserDataCallback, SharedErrorCallback);
            WaitForApiCalls();

            UUnitAssert.Equals("User Data Received", lastReceivedMessage);
            int.TryParse(testCounterReturn.Value, out testCounterValueExpected);
            testCounterValueExpected = (testCounterValueExpected + 1) % 100; // This test is about the expected value changing - but not testing more complicated issues like bounds

            var updateRequest = new UpdateUserDataRequest();
            updateRequest.Data = new Dictionary<string, string>();
            updateRequest.Data[TEST_DATA_KEY] = testCounterValueExpected.ToString();
            PlayFabClientAPI.UpdateUserData(updateRequest, UpdateUserDataCallback, SharedErrorCallback);
            WaitForApiCalls();

            UUnitAssert.StringEquals("User Data Updated", lastReceivedMessage);

            getRequest = new GetUserDataRequest();
            PlayFabClientAPI.GetUserData(getRequest, GetUserDataCallback, SharedErrorCallback);
            WaitForApiCalls();

            UUnitAssert.StringEquals("User Data Received", lastReceivedMessage);
            int.TryParse(testCounterReturn.Value, out testCounterValueActual);
            UUnitAssert.IntEquals(testCounterValueExpected, testCounterValueActual);

            DateTime timeUpdated = testCounterReturn.LastUpdated;
            DateTime minTest = DateTime.UtcNow - TimeSpan.FromMinutes(5);
            DateTime maxTest = DateTime.UtcNow + TimeSpan.FromMinutes(5);
            UUnitAssert.True(minTest <= timeUpdated && timeUpdated <= maxTest);

            // UnityEngine.Debug.Log((DateTime.UtcNow - timeUpdated).TotalSeconds);
            UUnitAssert.True(Math.Abs((DateTime.UtcNow - timeUpdated).TotalMinutes) < 5); // Make sure that this timestamp is recent - This must also account for the difference between local machine time and server time
        }
 private void LoadUserData(string authKey = null)
 {
     GetUserDataRequest request = new GetUserDataRequest ();
     PlayFabClientAPI.GetUserData (request, SetPlayerData, OnPlayFabError);
 }
	//get user data by keys
	public void GetUserDataByKey (string key)
	{
		List<string> lstKey = new List<string> ();
		lstKey.Add (key);

		GetUserDataRequest request = new GetUserDataRequest () {
			PlayFabId = CustomIDLogin,
			Keys = lstKey
		};

		PlayFabClientAPI.GetUserData (request, (result) => {
			Debug.Log ("Got user data:");
			if ((result.Data == null) || (result.Data.Count == 0)) {
				Debug.Log ("No user data available");
			} else {
				foreach (var item in result.Data) {
					Debug.Log ("    " + item.Key + " == " + item.Value.Value);
					//					DemoUI.instance.txtdemo.text += "\n" + "    " + item.Key + " == " + item.Value.Value;
				}
			}
		}, (error) => {
			Debug.Log ("Got error retrieving user data:");
			Debug.Log (error.ErrorMessage);
		});
	}
示例#15
0
        public void UserDataApi(UUnitTestContext testContext)
        {
            if (!TITLE_CAN_UPDATE_SETTINGS)
            {
                testContext.EndTest(UUnitFinishState.SKIPPED, "This title cannot update statistics from the client");
                return;
            }

            var getRequest = new GetUserDataRequest();
            PlayFabClientAPI.GetUserData(getRequest, PlayFabUUnitUtils.ApiCallbackWrapper<GetUserDataResult>(testContext, GetUserDataCallback1), SharedErrorCallback, testContext);
        }
示例#16
0
        public void UserDataApi()
        {
            string TEST_KEY = "testCounter";

            ClientModels.UserDataRecord testCounter;
            int testCounterValueExpected, testCounterValueActual;

            var getRequest = new ClientModels.GetUserDataRequest();
            var getDataTask1 = PlayFabClientAPI.GetUserDataAsync(getRequest);
            getDataTask1.Wait();
            UUnitAssert.Null(getDataTask1.Result.Error, "UserData should have been retrieved from Api call");
            UUnitAssert.NotNull(getDataTask1.Result.Result, "UserData should have been retrieved from Api call");
            UUnitAssert.NotNull(getDataTask1.Result.Result.Data, "UserData should have been retrieved from Api call");
            if (!getDataTask1.Result.Result.Data.TryGetValue(TEST_KEY, out testCounter))
            {
                testCounter = new ClientModels.UserDataRecord();
                testCounter.Value = "0";
            }
            int.TryParse(testCounter.Value, out testCounterValueExpected);
            testCounterValueExpected = (testCounterValueExpected + 1) % 100; // This test is about the expected value changing - but not testing more complicated issues like bounds

            var updateRequest = new ClientModels.UpdateUserDataRequest();
            updateRequest.Data = new Dictionary<string, string>();
            updateRequest.Data[TEST_KEY] = testCounterValueExpected.ToString();
            var updateTask = PlayFabClientAPI.UpdateUserDataAsync(updateRequest);
            updateTask.Wait(); // The update doesn't return anything interesting except versionID.  It's better to just re-call GetUserData again below to verify the update
            UUnitAssert.Null(updateTask.Result.Error, "UpdateUserData call failed");
            UUnitAssert.NotNull(updateTask.Result.Result, "UpdateUserData call failed");

            getRequest = new ClientModels.GetUserDataRequest();
            var getDataTask2 = PlayFabClientAPI.GetUserDataAsync(getRequest);
            getDataTask2.Wait();
            UUnitAssert.Null(getDataTask2.Result.Error, "UserData should have been retrieved from Api call");
            UUnitAssert.NotNull(getDataTask2.Result.Result, "UserData should have been retrieved from Api call");
            UUnitAssert.NotNull(getDataTask2.Result.Result.Data, "UserData should have been retrieved from Api call");
            getDataTask2.Result.Result.Data.TryGetValue(TEST_KEY, out testCounter);
            UUnitAssert.NotNull(testCounter, "The updated UserData was not found in the Api results");
            int.TryParse(testCounter.Value, out testCounterValueActual);
            UUnitAssert.Equals(testCounterValueExpected, testCounterValueActual);

            var timeUpdated = testCounter.LastUpdated;
            var testMin = DateTime.UtcNow - TimeSpan.FromMinutes(5);
            var testMax = testMin + TimeSpan.FromMinutes(10);
            UUnitAssert.True(testMin <= timeUpdated && timeUpdated <= testMax);
        }
示例#17
0
		/// <summary>
		/// Retrieves the title-specific custom data for the user which can only be read by the client
		/// </summary>
        public static async Task<PlayFabResult<GetUserDataResult>> GetUserReadOnlyDataAsync(GetUserDataRequest request)
        {
            if (AuthKey == null) throw new Exception ("Must be logged in to call this method");

            object httpResult = await PlayFabHTTP.DoPost(PlayFabSettings.GetURL() + "/Client/GetUserReadOnlyData", request, "X-Authorization", AuthKey);
            if(httpResult is PlayFabError)
            {
                PlayFabError error = (PlayFabError)httpResult;
                if (PlayFabSettings.GlobalErrorHandler != null)
                    PlayFabSettings.GlobalErrorHandler(error);
                return new PlayFabResult<GetUserDataResult>
                {
                    Error = error,
                };
            }
            string resultRawJson = (string)httpResult;

            var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings);
            var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetUserDataResult>>(new JsonTextReader(new StringReader(resultRawJson)));
			
			GetUserDataResult result = resultData.data;
			
			
            return new PlayFabResult<GetUserDataResult>
                {
                    Result = result
                };
        }
        /// <summary>
        /// Retrieves the publisher-specific custom data for the user which is readable and writable by the client
        /// </summary>
        public static void GetUserPublisherData(GetUserDataRequest request, GetUserPublisherDataCallback resultCallback, ErrorCallback errorCallback, object customData = null)
        {
            if (_authKey == null) throw new Exception("Must be logged in to call this method");

            string serializedJson = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings);
            Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer)
            {
                ResultContainer<GetUserDataResult>.HandleResults(requestContainer, resultCallback, errorCallback, null);
            };
            PlayFabHTTP.Post("/Client/GetUserPublisherData", serializedJson, "X-Authorization", _authKey, callback, request, customData);
        }
示例#19
0
		/// <summary>
		/// Retrieves the title-specific custom data for the user which can only be read by the client
		/// </summary>
		public static void GetUserReadOnlyData(GetUserDataRequest request, GetUserReadOnlyDataCallback resultCallback, ErrorCallback errorCallback)
		{
			if (AuthKey == null) throw new Exception ("Must be logged in to call this method");

			string serializedJSON = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings);
			Action<string,string> callback = delegate(string responseStr, string errorStr)
			{
				GetUserDataResult result = null;
				PlayFabError error = null;
				ResultContainer<GetUserDataResult>.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()+"/Client/GetUserReadOnlyData", serializedJSON, "X-Authorization", AuthKey, callback);
		}
示例#20
0
    void GetUserData()
    {
        GetUserDataRequest request = new GetUserDataRequest() {
            PlayFabId = PlayFabId,
            Keys = null
        };

        PlayFabClientAPI.GetUserData(request,(result) => {
            Debug.Log("Got user data:");
            if ((result.Data == null) || (result.Data.Count == 0)) {
                Debug.Log("No user data available");
            } else {
                win = int.Parse(result.Data["win"].Value);
                lose = int.Parse(result.Data["lose"].Value);
                Debug.Log("WIN: " + win + ", LOSE: " + lose);
            }
        }, (error) => {
            Debug.Log("Got error retrieving user data:");
            Debug.Log(error.ErrorMessage);
        });
    }
示例#21
0
        private void UpdateUserDataCallback(UpdateUserDataResult result)
        {
            var testContext = (UUnitTestContext)result.CustomData;

            var getRequest = new GetUserDataRequest();
            PlayFabClientAPI.GetUserData(getRequest, PlayFabUUnitUtils.ApiCallbackWrapper<GetUserDataResult>(testContext, GetUserDataCallback2), SharedErrorCallback, testContext);
        }
示例#22
0
    ////// GET USER DATA

    public static void get_user_data (){
        GetUserDataRequest request = new GetUserDataRequest();
		PlayFabClientAPI.GetUserData(request,get_user_data_successful,get_user_data_failed);
    }
 //Gets specific user's room name
 public static void GetUserRoomName(string playFabId)
 {
     var request = new GetUserDataRequest()
     {
         PlayFabId = playFabId   
     };
     PlayFabClientAPI.GetUserData(request, (result) =>
     {
         PlayFabDataStore.friendsCurrentRoomName = result.Data["RoomName"].Value;
         Debug.Log(result.Data["RoomName"].Value);
     },
     (error) =>
     {
         Debug.Log("Can't get Room Name");
         Debug.Log(error.ErrorMessage);
         Debug.Log(error.ErrorDetails);
     });
 }
	//get user data
	public void GetUserData (Action<Dictionary<string,string>> action)
	{
		GetUserDataRequest request = new GetUserDataRequest () {
			PlayFabId = CustomIDLogin,
			Keys = null
		};
		//PlayFabClientAPI.lead
		//PlayFabClientAPI.Upda
		PlayFabClientAPI.GetUserData (request, (result) => {
			Debug.Log ("Got user data:");
			if ((result.Data == null) || (result.Data.Count == 0)) {
				Debug.Log ("No user data available");
			} else {
				Dictionary<string,string> lstValueData = new Dictionary<string, string> ();
				foreach (var item in result.Data) {
					lstValueData.Add (item.Key, item.Value.Value);
				}
				action (lstValueData);
			}
		}, (error) => {
			Debug.Log ("Got error retrieving user data:");
			Debug.Log (error.ErrorMessage);
		});
	}