Inheritance: PlayFabRequestCommon
Beispiel #1
0
 public void AccountInfo()
 {
     ClientModels.GetAccountInfoRequest request = new ClientModels.GetAccountInfoRequest();
     request.PlayFabId = playFabId;
     var task = PlayFabClientAPI.GetAccountInfoAsync(request);
     task.Wait();
     UUnitAssert.Null(task.Result.Error, "Failed to get accountInfo");
     UUnitAssert.NotNull(task.Result.Result, "Failed to get accountInfo");
     UUnitAssert.NotNull(task.Result.Result.AccountInfo, "Failed to get accountInfo");
     UUnitAssert.NotNull(task.Result.Result.AccountInfo.TitleInfo, "Failed to get accountInfo");
     UUnitAssert.NotNull(task.Result.Result.AccountInfo.TitleInfo.Origination, "Failed to get Origination Enum");
     UUnitAssert.True(Enum.IsDefined(typeof(ClientModels.UserOrigination), task.Result.Result.AccountInfo.TitleInfo.Origination.Value), "Origination Enum not valid");
 }
Beispiel #2
0
 public void AccountInfo(UUnitTestContext testContext)
 {
     GetAccountInfoRequest request = new GetAccountInfoRequest
     {
         PlayFabId = _playFabId
     };
     PlayFabClientAPI.GetAccountInfo(request, PlayFabUUnitUtils.ApiCallbackWrapper<GetAccountInfoResult>(testContext, AcctInfoCallback), SharedErrorCallback, testContext);
 }
Beispiel #3
0
		/// <summary>
		/// Retrieves the user's PlayFab account details
		/// </summary>
		public static void GetAccountInfo(GetAccountInfoRequest request, GetAccountInfoCallback 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)
			{
				GetAccountInfoResult result = null;
				PlayFabError error = null;
				ResultContainer<GetAccountInfoResult>.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/GetAccountInfo", serializedJSON, "X-Authorization", AuthKey, callback);
		}
        /// <summary>
        /// Retrieves the user's PlayFab account details
        /// </summary>
        public static void GetAccountInfo(GetAccountInfoRequest request, ProcessApiCallback<GetAccountInfoResult> 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<GetAccountInfoResult>.HandleResults(requestContainer, resultCallback, errorCallback, null);
            };
            PlayFabHTTP.Post("/Client/GetAccountInfo", serializedJson, "X-Authorization", _authKey, callback, request, customData);
        }
        public void AccountInfo()
        {
            GetAccountInfoRequest request = new GetAccountInfoRequest();
            request.PlayFabId = playFabId;
            PlayFabClientAPI.GetAccountInfo(request, AcctInfoCallback, SharedErrorCallback);
            WaitForApiCalls();

            UUnitAssert.Equals("Enums tested", lastReceivedMessage);
        }
Beispiel #6
0
		/// <summary>
		/// Retrieves the user's PlayFab account details
		/// </summary>
        public static async Task<PlayFabResult<GetAccountInfoResult>> GetAccountInfoAsync(GetAccountInfoRequest request)
        {
            if (AuthKey == null) throw new Exception ("Must be logged in to call this method");

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

            var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings);
            var resultData = serializer.Deserialize<PlayFabJsonSuccess<GetAccountInfoResult>>(new JsonTextReader(new StringReader(resultRawJson)));
			
			GetAccountInfoResult result = resultData.data;
			
			
            return new PlayFabResult<GetAccountInfoResult>
                {
                    Result = result
                };
        }
 public void AccountInfo()
 {
     ClientModels.GetAccountInfoRequest request = new ClientModels.GetAccountInfoRequest();
     request.PlayFabId = playFabId;
     var task = Client.GetAccountInfoAsync(request);
     try
     {
         task.Wait();
     }
     catch(Exception ex)
     {
         UUnitAssert.True(false, ex.Message);
     }
     UUnitAssert.NotNull(task.Result, "Failed to get accountInfo");
     UUnitAssert.NotNull(task.Result.TitleInfo, "Failed to get accountInfo");
     UUnitAssert.NotNull(task.Result.TitleInfo.Origination, "Failed to get Origination Enum");
     UUnitAssert.True(Enum.IsDefined(typeof(ClientModels.UserOrigination), task.Result.TitleInfo.Origination.Value), "Origination Enum not valid");
 }
Beispiel #8
0
    public override void OnStartLocalPlayer()
    {
        if (LoginManager.instance.isGuest)
        {
            isGuest = true;

            CmdSetupPlayer("guest " + NetworkClient.connection.identity.netId, new Color(1f, 1f, 1f), Random.ColorHSV());
            CmdSendLoginMessage();
            return;
        }

        var userDataRequest = new GetUserDataRequest()
        {
            Keys = new List <string> {
                "rights"
            }
        };

        PlayFabClientAPI.GetUserData(userDataRequest, result =>
        {
            if (result.Data == null)
            {
                return;
            }

            if (result.Data.ContainsKey("rights"))
            {
                rights = Int16.Parse(result.Data["rights"].Value);
            }
        }, (error) =>
        {
            Debug.Log("Got error retrieving user data:");
            Debug.Log(error.GenerateErrorReport());
        });


        Color  nameColor;
        Color  matColor = Random.ColorHSV();
        string playerUserName;

        string email = String.IsNullOrEmpty(LoginManager.instance.emailField.text) ? PlayerPrefs.GetString("email") : LoginManager.instance.emailField.text;

        var accInfoRequest = new PlayFab.ClientModels.GetAccountInfoRequest {
            Email = email
        };

        PlayFabClientAPI.GetAccountInfo(accInfoRequest, (getResult) =>
        {
            playerUserName = getResult.AccountInfo.Username;

            if (rights > 1)
            {
                nameColor = new Color(255f, 174f, 0f);
            }
            else
            {
                nameColor = new Color(1f, 1f, 1f);
            }

            CmdSetupPlayer(playerUserName, nameColor, matColor);
            CmdSendLoginMessage();
        }, (error) =>
        {
            Debug.LogError(error);
            NetworkManager.singleton.StopClient();
        });

        playerEntity = LoginManager.instance.playerEntity;
    }