Inheritance: PlayFabRequestCommon
Esempio n. 1
0
        public static void LoginCallBack(LoginResult loginResult)
        {
            // CLIENT
            PfSharedModelEx.globalClientUser.playFabId = loginResult.PlayFabId;
            PfSharedControllerEx.PostEventMessage(PfSharedControllerEx.EventType.OnUserLogin, loginResult.PlayFabId, null, PfSharedControllerEx.Api.Client, false);
            var clientRequest = new ListUsersCharactersRequest();
            PlayFabClientAPI.GetAllUsersCharacters(clientRequest, ClientCharCallBack, PfSharedControllerEx.FailCallback("C_GetAllUsersCharacters"));

            // SERVER
            PfSharedModelEx.serverUsers.Add(loginResult.PlayFabId, PfSharedModelEx.globalClientUser); // Ensure that they share the same object reference
            var serverRequest = new ServerModels.ListUsersCharactersRequest();
            serverRequest.PlayFabId = loginResult.PlayFabId;
            PlayFabServerAPI.GetAllUsersCharacters(serverRequest, ServerCharCallBack, PfSharedControllerEx.FailCallback("S_GetAllUsersCharacters"));
        }
Esempio n. 2
0
 public void UserCharacter(UUnitTestContext testContext)
 {
     var request = new ListUsersCharactersRequest();
     request.PlayFabId = _playFabId; // Received from client upon login
     PlayFabClientAPI.GetAllUsersCharacters(request, PlayFabUUnitUtils.ApiCallbackWrapper<ListUsersCharactersResult>(testContext, GetCharsCallback), SharedErrorCallback, testContext);
 }
        public void UserCharacter()
        {
            var request = new ListUsersCharactersRequest();
            request.PlayFabId = playFabId; // Received from client upon login
            PlayFabClientAPI.GetAllUsersCharacters(request, GetCharsCallback, SharedErrorCallback);
            WaitForApiCalls();

            UUnitAssert.Equals("Get Chars Successful", lastReceivedMessage);
            UUnitAssert.NotNull(targetCharacter, "The test character did not exist");
        }
        /// <summary>
        /// Lists all of the characters that belong to a specific user. CharacterIds are not globally unique; characterId must be evaluated with the parent PlayFabId to guarantee uniqueness.
        /// </summary>
        public static void GetAllUsersCharacters(ListUsersCharactersRequest request, ProcessApiCallback<ListUsersCharactersResult> 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<ListUsersCharactersResult>.HandleResults(requestContainer, resultCallback, errorCallback, null);
            };
            PlayFabHTTP.Post("/Client/GetAllUsersCharacters", serializedJson, "X-Authorization", _authKey, callback, request, customData);
        }
    //Receives all characters belong to the user
    public static void GetAllUsersCharacters(string playfabId, string target)
    {
        var request = new ListUsersCharactersRequest()
        {
            PlayFabId = playfabId
        };

        PlayFabClientAPI.GetAllUsersCharacters(request, (result) =>
        {
            if (target == "Player")
            {
                foreach (var character in result.Characters)
                {
                    if (!PlayFabDataStore.characters.ContainsKey(character.CharacterName))
                    {
                        PlayFabDataStore.characters.Add(character.CharacterName, character.CharacterId);
                    }

                }
            }
            /*else
            {
                foreach (var character in result.Characters)
                {
                    if(character.CharacterName == PlayFabDataStore.friendUsername)
                    {
                        PlayFabDataStore.friendCharacterId = character.CharacterId;
                    }
                }
            }*/
            
        }, (error) =>
        {
            Debug.Log("Can't retrieve character!");
            Debug.Log(error.ErrorMessage);
            Debug.Log(error.ErrorDetails);
        });
    }
Esempio n. 6
0
 private void OnPfLoginComplete()
 {
     var charRequest = new ClientModels.ListUsersCharactersRequest();
     PlayFabClientAPI.GetAllUsersCharacters(charRequest, CharCallBack, SharedFailCallback("GetAllUsersCharacters"));
     var catalogRequest = new ClientModels.GetCatalogItemsRequest();
     PlayFabClientAPI.GetCatalogItems(catalogRequest, GetCatalogCallback, SharedFailCallback("GetCatalogItems"));
 }
Esempio n. 7
0
 private void OnPfLoginComplete()
 {
     var charRequest = new ClientModels.ListUsersCharactersRequest();
     PlayFabClientAPI.GetAllUsersCharacters(charRequest, CharCallBack, SharedFailCallback("GetAllUsersCharacters"));
     GetUserInventory();
 }
Esempio n. 8
0
		/// <summary>
		/// Lists all of the characters that belong to a specific user.
		/// </summary>
        public static async Task<PlayFabResult<ListUsersCharactersResult>> GetAllUsersCharactersAsync(ListUsersCharactersRequest request)
        {
            if (AuthKey == null) throw new Exception ("Must be logged in to call this method");

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

            var serializer = JsonSerializer.Create(PlayFabSettings.JsonSettings);
            var resultData = serializer.Deserialize<PlayFabJsonSuccess<ListUsersCharactersResult>>(new JsonTextReader(new StringReader(resultRawJson)));
			
			ListUsersCharactersResult result = resultData.data;
			
			
            return new PlayFabResult<ListUsersCharactersResult>
                {
                    Result = result
                };
        }
Esempio n. 9
0
		/// <summary>
		/// Lists all of the characters that belong to a specific user.
		/// </summary>
		public static void GetAllUsersCharacters(ListUsersCharactersRequest request, GetAllUsersCharactersCallback 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<string,PlayFabError> callback = delegate(string responseStr, PlayFabError pfError)
			{
				ListUsersCharactersResult result = null;
				ResultContainer<ListUsersCharactersResult>.HandleResults(responseStr, ref pfError, out result);
				if(pfError != null && errorCallback != null)
				{
					errorCallback(pfError);
				}
				if(result != null)
				{
					
					result.CustomData = customData;
					result.Request = request;
					if(resultCallback != null)
					{
						resultCallback(result);
					}
				}
			};
			PlayFabHTTP.Post(PlayFabSettings.GetURL()+"/Client/GetAllUsersCharacters", serializedJSON, "X-Authorization", AuthKey, callback);
		}