Exemplo n.º 1
0
        private void GetObjectCallback1(DataModels.GetObjectsResponse result)
        {
            var testContext = (UUnitTestContext)result.CustomData;

            _testInteger = 0; // Default if the data isn't present
            foreach (var eachObjPair in result.Objects)
            {
                if (eachObjPair.Key == TEST_OBJ_NAME)
                {
                    int.TryParse(eachObjPair.Value.EscapedDataObject, out _testInteger);
                }
            }

            _testInteger = (_testInteger + 1) % 100; // This test is about the Expected value changing - but not testing more complicated issues like bounds

            var updateRequest = new DataModels.SetObjectsRequest
            {
                Entity = new DataModels.EntityKey {
                    Id = _entityId, Type = _entityType
                },
                Objects = new List <DataModels.SetObject> {
                    new DataModels.SetObject {
                        ObjectName = TEST_OBJ_NAME, DataObject = _testInteger
                    }
                }
            };

            PlayFabDataAPI.SetObjects(updateRequest, PlayFabUUnitUtils.ApiActionWrapper <DataModels.SetObjectsResponse>(testContext, UpdateObjectCallback), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
    private void OnGetEntityTokenForSaveBackgroundColor(GetEntityTokenResponse getEntityTokenResponse)
    {
        var data = new Dictionary <string, object>()
        {
            { "R", Camera.main.backgroundColor.r },
            { "G", Camera.main.backgroundColor.g },
            { "B", Camera.main.backgroundColor.b },
            { "A", Camera.main.backgroundColor.a },
        };

        var dataList = new List <SetObject>()
        {
            new SetObject()
            {
                ObjectName = "BackgroundColor",
                DataObject = data
            }
        };

        var request = new SetObjectsRequest()
        {
            Entity = new PlayFab.DataModels.EntityKey {
                Id = getEntityTokenResponse.Entity.Id, Type = getEntityTokenResponse.Entity.Type
            },
            Objects = dataList
        };

        PlayFabDataAPI.SetObjects(request,
                                  delegate(SetObjectsResponse setObjectsResponse)
        {
            Debug.Log("Background color has been saved");
        },
                                  SharedError.OnSharedError);
    }
Exemplo n.º 3
0
    private void OnLoginSuccess(LoginResult result)
    {
        // Get Entity Information
        entityId   = result.EntityToken.Entity.Id;
        entityType = result.EntityToken.Entity.Type;

        // Get Account info to see if user has a linked account.
        var request = new GetAccountInfoRequest {
            PlayFabId = result.PlayFabId
        };

        PlayFabClientAPI.GetAccountInfo(request,
                                        resultA => {
            // If no linked account show the link account panel.
            if (resultA.AccountInfo.Username == "" || resultA.AccountInfo.Username == null &&
                (!PlayerPrefs.HasKey("LINK_ACCOUNT_REMINDER") || PlayerPrefs.GetInt("LINK_ACCOUNT_REMINDER") == 1))
            {
                panel.SetActive(true);
            }
        },
                                        error => { Debug.LogError(error.GenerateErrorReport()); });

        // Get object of title entity.
        var getRequest = new GetObjectsRequest {
            Entity = new EntityKey {
                Id = entityId, Type = entityType
            }
        };

        PlayFabDataAPI.GetObjects(getRequest,
                                  r => {
            // If user has no pc yet, create one with the server function.
            if (!r.Objects.ContainsKey("pc1"))
            {
                var cloudscriptrequest = new ExecuteEntityCloudScriptRequest {
                    FunctionName = "createFirstComputer", GeneratePlayStreamEvent = true
                };
                PlayFabCloudScriptAPI.ExecuteEntityCloudScript(cloudscriptrequest,
                                                               re => {
                    GameManager.gm.SetComputer("cpu1", "mem1");
                },
                                                               error => { Debug.LogError(error.GenerateErrorReport()); });
            }
            else
            {
                JsonObject jsonResult = (JsonObject)r.Objects["pc1"].DataObject;

                GameManager.gm.SetComputer(jsonResult["cpu"].ToString(), jsonResult["memory"].ToString());
            }

            // A way to loop through dictionary.

            /*foreach(KeyValuePair<string, ObjectResult> obj in r.Objects)
             * {
             *  Debug.Log(obj.Key);
             *  Debug.Log(obj.Value.ObjectName);
             * }*/
        },
                                  error => { });
    }
Exemplo n.º 4
0
    public override void Execute()
    {
        Debug.Log("wehere");
        var data = new Dictionary <string, object>()
        {
            { "Health", 100 },
            { "Mana", 10000 }
        };

        var dataList = new List <SetObject>()
        {
            new SetObject()
            {
                ObjectName = "PlayerData",
                DataObject = data
            }
        };

        if (_args is EntityTestCommandArgs getAccountInfoArgs)
        {
            string entityType = "title_player_account";

            var request = new SetObjectsRequest
            {
                Entity = new PlayFab.DataModels.EntityKey
                {
                    Type = entityType,
                    Id   = GameController.Instance.EntityTokens[entityType]
                },
                Objects = dataList
            };

            PlayFabDataAPI.SetObjects(request, OnSetObjects, OnHttpError);
        }
    }
Exemplo n.º 5
0
    /*
     *  Find the entity group for the player's wish list, or create one if does not exist
     *
     *  @param player_entityKeyId: the entity ID of the player; for a title entity the ID should be;
     *      in most cases, this can be found in LoginResult.EntityToken.Entity.Id
     *  @param player_entityKeyType: the entity type of the player whose wish list we are searching
     *      for; should be title_player_account entity in most cases
     *
     */

    public static void FindOrCreateWishList(string player_entityKeyId, string player_entityKeyType)
    {
        PlayFab.DataModels.EntityKey ent = new PlayFab.DataModels.EntityKey {
            Id = player_entityKeyId, Type = player_entityKeyType
        };

        var req = new PlayFab.DataModels.GetObjectsRequest {
            Entity = ent
        };

        PlayFabDataAPI.GetObjects(req, result => {
            if (!result.Objects.ContainsKey("wishlist"))
            {
                // Empty so need to create
                CreateEntityWishList();
            }
            else
            {
                string wl = (string)result.Objects["wishlist"].DataObject;

                // Exists so can set up store
                StoreSetup.SetUpStore(wl, false);
            }
        }, error => { Debug.LogError(error.GenerateErrorReport()); });
    }
Exemplo n.º 6
0
    private void LoadMeetings()
    {
        GameObject meetingEntry;



        PlayFabDataAPI.GetObjects(new GetObjectsRequest()
        {
            Entity = player.playerEntity
        }, (getResult) =>
        {
            myMeetings = getResult.Objects;
            foreach (KeyValuePair <string, PlayFab.DataModels.ObjectResult> entry in myMeetings)
            {
                Meeting obj = JsonUtility.FromJson <Meeting>(entry.Value.DataObject.ToString());

                meetingEntry = Instantiate(meetingEntryPrefab, transform);
                meetingEntry.transform.GetChild(0).GetComponent <Text>().text = entry.Key.ToString();
                if (obj.building_id != 0)
                {
                    meetingEntry.transform.GetChild(3).GetComponent <Text>().text = buildingDropDown.transform.GetComponent <Dropdown>().options[obj.building_id].text;
                }
                meetingEntry.transform.GetChild(1).GetComponent <Button>().onClick.AddListener(delegate() {
                    JoinClicked(obj);
                });
                meetingEntry.transform.GetChild(2).GetComponent <Button>().onClick.AddListener(delegate() {
                    DeleteClicked(entry.Key);
                });
            }
        }, error =>
        {
            Debug.LogError(error);
        }
                                  );
    }
Exemplo n.º 7
0
        void DeleteFiles(UUnitTestContext testContext, List <string> fileName, bool shouldEndTest, UUnitFinishState finishState, string finishMessage)
        {
            if (!_shouldDeleteFiles) // Only delete the file if it was created
            {
                return;
            }

            var request = new DataModels.DeleteFilesRequest
            {
                Entity = new DataModels.EntityKey {
                    Id = _entityId, Type = _entityType
                },
                FileNames = fileName,
            };

            _shouldDeleteFiles = false; // We have successfully deleted the file, it should not try again in teardown
            PlayFabDataAPI.DeleteFiles(request, result =>
            {
                if (shouldEndTest)
                {
                    testContext.EndTest(finishState, finishMessage);
                }
            },
                                       PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Exemplo n.º 8
0
        void OnInitFailed(PlayFabError error)
        {
            var testContext = (UUnitTestContext)error.CustomData;

            if (error.Error == PlayFabErrorCode.EntityFileOperationPending)
            {
                var request = new DataModels.AbortFileUploadsRequest
                {
                    Entity = new DataModels.EntityKey {
                        Id = _entityId, Type = _entityType
                    },
                    FileNames = new List <string> {
                        TEST_FILE_NAME
                    },
                };

                PlayFabDataAPI.AbortFileUploads(request, PlayFabUUnitUtils.ApiActionWrapper <DataModels.AbortFileUploadsResponse>(testContext, OnAbortFileUpload), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
            }
            else
            {
                if (error.CustomData != null)
                {
                    SharedErrorCallback(error);
                }
                else
                {
                    testContext.Fail(error.ErrorMessage);
                }
            }
        }
Exemplo n.º 9
0
    /*
     *
     *  Execute a PlayFab Cloud Script function to update the group entity object data to the
     *  updated CSV. Title-level data should not be changed directly from the client.
     *
     *  @param dataobj: the updated CSV; the Cloud Script function sets the entity group object data to
     *      this value.
     *  @param item_id: ItemID of the item that was either added or removed
     *
     */

    private void UpdateObject(string dataobj, bool adding_item, string item_id)
    {
        PlayFab.DataModels.EntityKey entity = new PlayFab.DataModels.EntityKey {
            Id = LoginClass.getPlayerEntityKeyId(), Type = LoginClass.getPlayerEntityKeyType()
        };

        List <PlayFab.DataModels.SetObject> ObjList = new List <PlayFab.DataModels.SetObject>();

        ObjList.Add(

            new PlayFab.DataModels.SetObject {
            ObjectName = "wishlist",
            DataObject = dataobj
        }

            );

        var request = new PlayFab.DataModels.SetObjectsRequest {
            Entity  = entity,
            Objects = ObjList
        };

        PlayFabDataAPI.SetObjects(request, result => {
            if (adding_item)
            {
                StoreSetup.SetUpStore(item_id, false);
            }
            else
            {
                StoreSetup.SetUpStore(item_id, true);
            }
        }, error => { Debug.LogError(error.GenerateErrorReport()); });
    }
Exemplo n.º 10
0
    public void AttemptEnterBuilding(int buildingId)
    {
        if (!isLocalPlayer || playerEntity == null || isGuest)
        {
            return;
        }

        var request = new GetObjectsRequest {
            Entity = playerEntity
        };

        PlayFabDataAPI.GetObjects(request, (getResult) =>
        {
            var courses = getResult.Objects;
            foreach (KeyValuePair <string, PlayFab.DataModels.ObjectResult> entry in courses)
            {
                Meeting obj = JsonUtility.FromJson <Meeting>(entry.Value.DataObject.ToString());

                if (obj.building_id == buildingId)
                {
                    Application.ExternalEval("window.open(\"http://umass-amherst.zoom.us/j/" + obj.meeting_id + "\")");

                    if (obj.password != "")
                    {
                        // show password copied to clipboard dialog
                        GUIUtility.systemCopyBuffer = obj.password;
                    }

                    break;
                }
            }
        }, GetObjectsFailure
                                  );
    }
Exemplo n.º 11
0
        private void GetObjects1Continued(PlayFabResult <GetObjectsResponse> result, UUnitTestContext testContext, string failMessage)
        {
            // testContext.IntEquals(result.Result.Objects.Count, 1);
            // testContext.StringEquals(result.Result.Objects[0].ObjectName, TEST_DATA_KEY);

            _testInteger = 0;
            if (result.Result.Objects.Count == 1 && result.Result.Objects[TEST_DATA_KEY].ObjectName == TEST_DATA_KEY)
            {
                int.TryParse(result.Result.Objects[TEST_DATA_KEY].EscapedDataObject, out _testInteger);
            }

            var request = new SetObjectsRequest
            {
                Entity = new DataModels.EntityKey
                {
                    Id   = entityId,
                    Type = entityType,
                },
                Objects = new List <SetObject>
                {
                    new SetObject
                    {
                        DataObject = _testInteger,
                        ObjectName = TEST_DATA_KEY
                    }
                }
            };
            var eachTask = PlayFabDataAPI.SetObjectsAsync(request, null, extraHeaders);

            ContinueWithContext(eachTask, testContext, SetObjectsContinued, true, "SetObjects failed", false);
        }
Exemplo n.º 12
0
    public void AddMeeting()
    {
        feedbackText.text = "";

        if (String.IsNullOrEmpty(meetingIdField.text) || String.IsNullOrEmpty(meetingNameField.text))
        {
            feedbackText.text = "Must complete all of the required fields to add a meeting";
            return;
        }

        meetingNameField.text = meetingNameField.text.Replace(" ", "");

        List <SetObject> meetingList = new List <SetObject>();

        Dictionary <string, object> meetingData = new Dictionary <string, object>()
        {
            { "meeting_id", meetingIdField.text },
            { "building_id", buildingId },
            { "meeting_password", passwordField.text }
        };

        string    meetingJson = JsonUtility.ToJson(meetingData);
        SetObject meeting     = new SetObject()
        {
            ObjectName = meetingNameField.text, DataObject = meetingData
        };
        ObjectResult entry = new ObjectResult()
        {
            ObjectName = meetingNameField.text, DataObject = meetingJson
        };

        meetingList.Add(meeting);
        myMeetings.Add(meetingNameField.text, entry);

        PlayFabDataAPI.SetObjects(new SetObjectsRequest()
        {
            Entity  = LoginManager.instance.playerEntity,
            Objects = meetingList
        }, (setResult) =>
        {
            ReloadMeetings();

            meetingNameField.text = "";
            meetingIdField.text   = "";
            passwordField.text    = "";
            buildingDropDown.GetComponent <Dropdown>().value = 0;
            buildingId = 0;

            feedbackText.color = new Color(103f, 255f, 157f);
            feedbackText.text  = "Meeting added successfully!";
        }, (error) =>
        {
            Debug.LogError(error.GenerateErrorReport());
            feedbackText.color = new Color(255f, 81f, 81f);
            feedbackText.text  = "Too many meetings, you have to delete one first.";
        }
                                  );
    }
Exemplo n.º 13
0
        public void ObjectApi(UUnitTestContext testContext)
        {
            var getRequest = new DataModels.GetObjectsRequest {
                Entity = new DataModels.EntityKey {
                    Id = _entityId, Type = _entityType
                }, EscapeObject = true
            };

            PlayFabDataAPI.GetObjects(getRequest, PlayFabUUnitUtils.ApiActionWrapper <DataModels.GetObjectsResponse>(testContext, GetObjectCallback1), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
    private void OnGetEntityTokenForGetBackgroundColor(GetEntityTokenResponse response)
    {
        var request = new GetObjectsRequest
        {
            Entity = new PlayFab.DataModels.EntityKey {
                Id = response.Entity.Id, Type = response.Entity.Type
            }
        };

        PlayFabDataAPI.GetObjects(request, OnGetObjectsSuccess, SharedError.OnSharedError);
    }
Exemplo n.º 15
0
        private void LoadFiles(UUnitTestContext testContext)
        {
            var request = new DataModels.GetFilesRequest
            {
                Entity = new DataModels.EntityKey {
                    Id = _entityId, Type = _entityType
                },
            };

            PlayFabDataAPI.GetFiles(request, PlayFabUUnitUtils.ApiActionWrapper <DataModels.GetFilesResponse>(testContext, OnGetFilesInfo), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Exemplo n.º 16
0
        private void UpdateObjectCallback(DataModels.SetObjectsResponse result)
        {
            var testContext = (UUnitTestContext)result.CustomData;

            var getRequest = new DataModels.GetObjectsRequest {
                Entity = new DataModels.EntityKey {
                    Id = _entityId, Type = _entityType
                }, EscapeObject = true
            };

            PlayFabDataAPI.GetObjects(getRequest, PlayFabUUnitUtils.ApiActionWrapper <DataModels.GetObjectsResponse>(testContext, GetObjectCallback2), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Exemplo n.º 17
0
        void FinalizeUpload(UUnitTestContext testContext)
        {
            var request = new DataModels.FinalizeFileUploadsRequest
            {
                Entity = new DataModels.EntityKey {
                    Id = _entityId, Type = _entityType
                },
                FileNames = new List <string> {
                    TEST_FILE_NAME
                },
            };

            PlayFabDataAPI.FinalizeFileUploads(request, PlayFabUUnitUtils.ApiActionWrapper <DataModels.FinalizeFileUploadsResponse>(testContext, OnUploadSuccess), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Exemplo n.º 18
0
        private void SetObjectsContinued(PlayFabResult <SetObjectsResponse> result, UUnitTestContext testContext, string failMessage)
        {
            var request = new GetObjectsRequest
            {
                Entity = new DataModels.EntityKey
                {
                    Id   = entityId,
                    Type = entityType,
                },
                EscapeObject = true
            };
            var eachTask = PlayFabDataAPI.GetObjectsAsync(request, null, extraHeaders);

            ContinueWithContext(eachTask, testContext, GetObjects2Continued, true, "GetObjects2 failed", false);
        }
Exemplo n.º 19
0
        public void ObjectApi(UUnitTestContext testContext)
        {
            var request = new GetObjectsRequest
            {
                Entity = new DataModels.EntityKey
                {
                    Id   = entityId,
                    Type = entityType,
                },
                EscapeObject = true
            };
            var eachTask = PlayFabDataAPI.GetObjectsAsync(request, null, extraHeaders);

            ContinueWithContext(eachTask, testContext, GetObjects1Continued, true, "GetObjects1 failed", false);
        }
Exemplo n.º 20
0
        void UploadFile(UUnitTestContext testContext, string fileName)
        {
            var request = new DataModels.InitiateFileUploadsRequest
            {
                Entity = new DataModels.EntityKey {
                    Id = _entityId, Type = _entityType
                },
                FileNames = new List <string>
                {
                    fileName
                },
            };

            PlayFabDataAPI.InitiateFileUploads(request, PlayFabUUnitUtils.ApiActionWrapper <DataModels.InitiateFileUploadsResponse>(testContext, OnInitFileUpload), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, OnInitFailed), testContext);
        }
Exemplo n.º 21
0
    private void LoadAllFiles()
    {
        if (GlobalFileLock != 0)
        {
            throw new Exception("This example overly restricts file operations for safety. Careful consideration must be made when doing multiple file operations in parallel to avoid conflict.");
        }

        GlobalFileLock += 1; // Start GetFiles
        var request = new PlayFab.DataModels.GetFilesRequest {
            Entity = new PlayFab.DataModels.EntityKey {
                Id = entityId, Type = entityType
            }
        };

        PlayFabDataAPI.GetFiles(request, OnGetFileMeta, OnSharedFailure);
    }
Exemplo n.º 22
0
    void DeleteFile(string file)
    {
        GlobalFileLock += 1;
        var request = new PlayFab.DataModels.DeleteFilesRequest
        {
            Entity = new PlayFab.DataModels.EntityKey {
                Id = entityId, Type = entityType
            },
            FileNames = new List <string> {
                file
            },
        };

        PlayFabDataAPI.DeleteFiles(request, OnDeleteFilesSuccess, OnSharedFailure);
        keys.Remove(file);
    }
Exemplo n.º 23
0
    void FinalizeUpload(byte[] data)
    {
        GlobalFileLock += 1; // Start FinalizeFileUploads
        var request = new PlayFab.DataModels.FinalizeFileUploadsRequest
        {
            Entity = new PlayFab.DataModels.EntityKey {
                Id = entityId, Type = entityType
            },
            FileNames = new List <string> {
                ActiveUploadFileName
            },
        };

        PlayFabDataAPI.FinalizeFileUploads(request, OnUploadSuccess, OnSharedFailure);
        GlobalFileLock -= 1; // Finish SimplePutCall
    }
Exemplo n.º 24
0
    /*
     *
     *  If the item is on the wish list, remove it. If the item is not on the wish list, add it.
     *
     *  @param item_id: ItemID of the item to be added to or remove from the wishlist
     *
     *  This function gets the "wishlist" object from the entity group data. If the item is on the wish list,
     *  this function updates the CSV by removing it. If the item is not on the wish list, this function
     *  updates the CSV by adding it. It then calls UpdateGroupObject, which updates the actual entity group data.
     *
     */

    public void UpdateWishlist(string item_id)
    {
        /* Create entity key and request to get object data from group. */
        PlayFab.DataModels.EntityKey group_ek = new PlayFab.DataModels.EntityKey {
            Id = WishList.group_entityKeyId, Type = WishList.group_entityKeyType
        };
        GetObjectsRequest getObjectsRequest = new GetObjectsRequest {
            Entity = group_ek
        };

        /* GetObjects to get the wish list in CSV form. */
        PlayFabDataAPI.GetObjects(getObjectsRequest, objectResult => {
            string wl;
            bool adding_item; // This tells us whether we are adding or removing an item from the wish list


            if (!string.IsNullOrEmpty((string)objectResult.Objects["wishlist"].DataObject))
            {
                wl = (string)objectResult.Objects["wishlist"].DataObject;  // string of the CSV of items on the wish list

                if (!WishlistContainsItem(wl, item_id))
                {
                    /* Wish list does not contain the item, so we must add it. */
                    wl          = AddItemToCSV(wl, item_id);
                    adding_item = true;
                }
                else
                {
                    /* Wish list contains item, so we must remove it. */
                    wl          = RemoveItemFromCSV(wl, item_id);
                    adding_item = false;
                }
            }
            else
            {
                wl          = item_id;
                adding_item = true;
            }

            /* UpdateGroupObject is where the entity group data is actually updated */
            UpdateGroupObject(wl, adding_item, item_id);
        }, error => {
            Debug.LogError(error.GenerateErrorReport());
        });
    }
Exemplo n.º 25
0
    private void UploadLevelDataFile()
    {
        if (GlobalFileLock != 0)
        {
            throw new Exception("This example overly restricts file operations for safety. Careful consideration must be made when doing multiple file operations in parallel to avoid conflict.");
        }

        GlobalFileLock += 1; // Start InitiateFileUploads
        var request = new PlayFab.DataModels.InitiateFileUploadsRequest
        {
            Entity = new PlayFab.DataModels.EntityKey {
                Id = entityId, Type = entityType
            },
            FileNames = new List <string> {
                levelDataFilePath
            },
        };

        PlayFabDataAPI.InitiateFileUploads(request, OnInitFileUpload, OnSharedFailure);
    }
Exemplo n.º 26
0
        void RetrieveCharacterData(ushort ConnectedClientID, string characterID)
        {
            PlayFab.DataModels.EntityKey characterEntityKey = CreateKeyForEntity(characterID, "character");
            GetObjectsRequest            getObjectsRequest  = CreateGetCharacterObjectRequestEscaped(characterEntityKey);

            PlayFabDataAPI.GetObjects(getObjectsRequest,
                                      result =>
            {
                PlayFabCharacterData characterData = PlayFabSimpleJson.DeserializeObject <PlayFabCharacterData>(result.Objects["CharacterData"].EscapedDataObject);
                Debug.Log($"character position for retrieved character: {characterData.WorldPositionX}, {characterData.WorldPositionY}, {characterData.WorldPositionZ}");
                characterData.SetWorldPosition(characterData.WorldPositionX, characterData.WorldPositionY, characterData.WorldPositionZ);
                Debug.Log($"character position AS VECTOR 3 for retrieved character: {characterData.WorldPosition.ToString()}");

                SetCurrentCharacterDataForConnectedClient(ConnectedClientID, characterData);
            }, error =>
            {
                Debug.Log("Error setting player info from PlayFab result object");
                Debug.Log(error.ErrorMessage);
            });
        }
Exemplo n.º 27
0
    /*
     *
     *  This function gets a player's wish list.
     *
     *  @param PlayFabID: the PlayFabId of the user whose wish list we want to see
     *
     */

    public static void ViewPlayerWishList(string PlayFabID)
    {
        /* We have their PlayFabID, but we need their title player ID in order to make an entity key. */

        PlayFabClientAPI.GetAccountInfo(new PlayFab.ClientModels.GetAccountInfoRequest {
            PlayFabId = PlayFabID
        }, AccountInfoResult => {
            /* The below contains the title player Id */

            var id = AccountInfoResult.AccountInfo.TitleInfo.TitlePlayerAccount.Id;

            /* Now that we have their title player ID, we can use GetObjects to get their wish list */

            PlayFabDataAPI.GetObjects(new PlayFab.DataModels.GetObjectsRequest {
                /* GetObjects has an entity key parameter */

                Entity = new PlayFab.DataModels.EntityKey {
                    Id = id, Type = "title_player_account"
                }
            }, GetObjectsResult => {
                /*
                 *  GetObjects returns a dictionary of objects. We are interested in the "wishlist"
                 *  key-value pair.
                 */

                if (GetObjectsResult.Objects.ContainsKey("wishlist"))
                {
                    Debug.Log(GetObjectsResult.Objects["wishlist"].DataObject);
                }
                else
                {
                    Debug.Log("Player has no wish list");
                }
            }, error => { Debug.LogError(error.GenerateErrorReport()); });
        }, error => {
            Debug.LogError(error.GenerateErrorReport());
        });
    }
Exemplo n.º 28
0
        void SaveCharacterData(PlayFabCharacterData characterData)
        {
            var dataList = new List <SetObject>();

            dataList.Add(ReturnNewSetObject("CharacterData", SetCharacterInfoData(characterData)));

            PlayFab.DataModels.EntityKey characterEntityKey = CreateKeyForEntity(characterData.CharacterID, "character");

            SetObjectsRequest setCharacterObjectDataRequest = new SetObjectsRequest()
            {
                Entity  = characterEntityKey,
                Objects = dataList
            };

            PlayFabDataAPI.SetObjects(setCharacterObjectDataRequest,
                                      result =>
            {
                if (characterData.IsInitialCharacterData)
                {
                    ushort clientID = ReturnClientConnectionByPlayFabCharacterID(characterData);

                    if (clientID != 9999)
                    {
                        ServerManager.Instance.SendToClient(clientID, Tags.RegisterNewCharacterResponse, new RegisterNewCharacterResponseData(true));
                    }
                    else
                    {
                        ServerManager.Instance.SendToClient(clientID, Tags.RegisterNewCharacterResponse, new RegisterNewCharacterResponseData(false));
                    }
                }
            },
                                      error =>
            {
                Debug.Log($"Failed to save character state data");
                Debug.Log(error.ErrorMessage);
                Debug.Log(error.ErrorDetails);
            });
        }
Exemplo n.º 29
0
    private void DeleteClicked(string key)
    {
        meetingNameField.text = "";
        meetingIdField.text   = "";
        passwordField.text    = "";
        buildingDropDown.GetComponent <Dropdown>().value = 0;
        buildingId = 0;

        feedbackText.text = "";

        myMeetings.Remove(key);

        List <SetObject> meetingList = new List <SetObject>();

        SetObject meeting = new SetObject()
        {
            ObjectName = key, DeleteObject = true
        };

        meetingList.Add(meeting);

        PlayFabDataAPI.SetObjects(new SetObjectsRequest()
        {
            Entity  = player.playerEntity,
            Objects = meetingList
        }, (setResult) =>
        {
            feedbackText.text = "Meeting deleted successfully";
            ReloadMeetings();
        }, (error) =>
        {
            Debug.LogError(error.GenerateErrorReport());

            feedbackText.color = new Color(255f, 81f, 81f);
            feedbackText.text  = "Couldn't delete meeting.";
        }
                                  );
    }
Exemplo n.º 30
0
 void OnInitFailed(PlayFabError error)
 {
     if (error.Error == PlayFabErrorCode.EntityFileOperationPending)
     {
         // This is an error you should handle when calling InitiateFileUploads, but your resolution path may vary
         GlobalFileLock += 1; // Start AbortFileUploads
         var request = new PlayFab.DataModels.AbortFileUploadsRequest
         {
             Entity = new PlayFab.DataModels.EntityKey {
                 Id = entityId, Type = entityType
             },
             FileNames = new List <string> {
                 ActiveUploadFileName
             },
         };
         PlayFabDataAPI.AbortFileUploads(request, (result) => { GlobalFileLock -= 1; UploadFile(ActiveUploadFileName); }, OnSharedFailure); GlobalFileLock -= 1; // Finish AbortFileUploads
         GlobalFileLock -= 1;                                                                                                                                    // Failed InitiateFileUploads
     }
     else
     {
         OnSharedFailure(error);
     }
 }