Ejemplo n.º 1
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
                                  );
    }
Ejemplo n.º 2
0
        public void ObjectApi(UUnitTestContext testContext)
        {
            var getRequest = new GetObjectsRequest {
                Entity = _entityKey, EscapeObject = true
            };

            PlayFabEntityAPI.GetObjects(getRequest, PlayFabUUnitUtils.ApiActionWrapper <GetObjectsResponse>(testContext, GetObjectCallback1), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieves objects from an entity's profile.
        /// </summary>
        public static void GetObjects(GetObjectsRequest request, Action<GetObjectsResponse> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
        {
            var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
            var callSettings = PlayFabSettings.staticSettings;
            if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");


            PlayFabHttp.MakeApiCall("/Object/GetObjects", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
        }
Ejemplo n.º 4
0
        private void UpdateObjectCallback(SetObjectsResponse result)
        {
            var testContext = (UUnitTestContext)result.CustomData;

            var getRequest = new GetObjectsRequest {
                Entity = _entityKey, EscapeObject = true
            };

            PlayFabEntityAPI.GetObjects(getRequest, PlayFabUUnitUtils.ApiActionWrapper <GetObjectsResponse>(testContext, GetObjectCallback2), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
        }
Ejemplo n.º 5
0
        private void SetObjectsContinued(PlayFabResult <SetObjectsResponse> result, UUnitTestContext testContext, string failMessage)
        {
            var request = new GetObjectsRequest
            {
                Entity       = entityKey,
                EscapeObject = true
            };
            var eachTask = PlayFabEntityAPI.GetObjectsAsync(request, null, extraHeaders);

            ContinueWithContext(eachTask, testContext, GetObjects2Continued, true, "GetObjects2 failed", false);
        }
    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);
    }
Ejemplo n.º 7
0
        public void ObjectApi(UUnitTestContext testContext)
        {
            var request = new GetObjectsRequest
            {
                Entity       = entityKey,
                EscapeObject = true
            };
            var eachTask = PlayFabEntityAPI.GetObjectsAsync(request, null, extraHeaders);

            ContinueWithContext(eachTask, testContext, GetObjects1Continued, true, "GetObjects1 failed", false);
        }
Ejemplo n.º 8
0
        public static async Task <GetObjectsResponse> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] FunctionExecutionContext req,
            HttpRequest httpRequest,
            ILogger log)
        {
            string body = await httpRequest.ReadAsStringAsync();

            log.LogInformation($"HTTP POST Body: {body}");

            log.LogInformation($"callingEntityKey: {JsonConvert.SerializeObject(req.CallerEntityProfile.Entity)}");
            log.LogInformation($"currentEntity: {JsonConvert.SerializeObject(req.CallerEntityProfile)}");

            var titleSettings = new PlayFabApiSettings
            {
                TitleId = req.TitleAuthenticationContext.Id,
                //VerticalName = Settings.Cloud
                DeveloperSecretKey = Settings.TitleSecret
            };

            var titleAuthContext = new PlayFabAuthenticationContext();

            titleAuthContext.EntityToken = req.TitleAuthenticationContext.EntityToken;

            var api = new PlayFabDataInstanceAPI(titleSettings, titleAuthContext);

            var getObjectsRequest = new GetObjectsRequest
            {
                Entity = new DataModels.EntityKey
                {
                    Id   = req.CallerEntityProfile.Entity.Id,
                    Type = req.CallerEntityProfile.Entity.Type
                }
            };

            Stopwatch sw = Stopwatch.StartNew();
            PlayFabResult <GetObjectsResponse> getObjectsResponse = await api.GetObjectsAsync(getObjectsRequest);

            sw.Stop();

            if (getObjectsResponse.Error != null)
            {
                throw new InvalidOperationException($"GetObjectsAsync failed: {getObjectsResponse.Error.GenerateErrorReport()}");
            }
            else
            {
                log.LogInformation($"GetObjectsAsync succeeded in {sw.ElapsedMilliseconds}ms");
                log.LogInformation($"GetObjectsAsync returned. ProfileVersion: {getObjectsResponse.Result.ProfileVersion}. Entity: {getObjectsResponse.Result.Entity.Id}/{getObjectsResponse.Result.Entity.Type}. NumObjects: {getObjectsResponse.Result.Objects.Count}.");
                return(getObjectsResponse.Result);
            }
        }
Ejemplo n.º 9
0
        private void SetObjectsContinued(PlayFabResult <SetObjectsResponse> result, UUnitTestContext testContext, string failMessage)
        {
            var request = new GetObjectsRequest
            {
                Entity = new DataModels.EntityKey
                {
                    Id   = PlayFabSettings.staticPlayer.EntityId,
                    Type = PlayFabSettings.staticPlayer.EntityType,
                },
                EscapeObject = true
            };
            var eachTask = dataApi.GetObjectsAsync(request, null, testTitleData.extraHeaders);

            ContinueWithContext(eachTask, testContext, GetObjects2Continued, true, "GetObjects2 failed", false);
        }
Ejemplo n.º 10
0
        public void ObjectApi(UUnitTestContext testContext)
        {
            var request = new GetObjectsRequest
            {
                Entity = new DataModels.EntityKey
                {
                    Id   = PlayFabSettings.staticPlayer.EntityId,
                    Type = PlayFabSettings.staticPlayer.EntityType,
                },
                EscapeObject = true
            };
            var eachTask = dataApi.GetObjectsAsync(request, null, testTitleData.extraHeaders);

            ContinueWithContext(eachTask, testContext, GetObjects1Continued, true, "GetObjects1 failed", false);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Retrieves objects from an entity's profile.
        /// </summary>
        /// <param name="Entity">The entity to perform this action on. (Required)</param>
        /// <param name="EscapeObject">Determines whether the object will be returned as an escaped JSON string or as a un-escaped JSON object. Default is JSON object. (Optional)</param>
        public static Task <GetObjectsResponse> GetObjects(EntityKey Entity, bool?EscapeObject            = default,
                                                           PlayFabAuthenticationContext customAuthContext = null, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            GetObjectsRequest request = new GetObjectsRequest()
            {
                Entity       = Entity,
                EscapeObject = EscapeObject,
            };

            var context = GetContext(customAuthContext);

            return(PlayFabHttp.MakeApiCallAsync <GetObjectsResponse>("/Object/GetObjects", request,
                                                                     AuthType.EntityToken,
                                                                     customData, extraHeaders, context));
        }
Ejemplo n.º 12
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());
        });
    }
Ejemplo n.º 13
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);
            });
        }
Ejemplo n.º 14
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
     *
     *  Upon login, this function examines all entity groups that the player belongs to. For each group,
     *  the group name is compared to the nomenclature for wish list groups. If the group is not found,
     *  then one is created
     */

    public static void FindOrCreateWishList(string player_entityKeyId, string player_entityKeyType)
    {
        /* Create entity key for the ListMembership request */

        PlayFab.GroupsModels.EntityKey entity = new PlayFab.GroupsModels.EntityKey {
            Id = player_entityKeyId, Type = player_entityKeyType
        };

        var request = new ListMembershipRequest {
            Entity = entity
        };

        PlayFabGroupsAPI.ListMembership(request, membershipResult => {
            bool found = false; // Will tell us whether the wish list entity group exists

            /*
             *  Iterate through all groups the player belongs to. If the wish list entity group exists,
             *  it should be one of these groups
             */

            for (int i = 0; i < membershipResult.Groups.Count; i++)
            {
                string group_name = LoginClass.getPlayerEntityKeyId() + "wishlist";

                /* Compare the name of the group to the nomenclature the wish list entity group name will follow */

                if (membershipResult.Groups[i].GroupName.Equals(group_name))
                {
                    found = true; // If the name matches, we found the wish list entity group

                    /* Set the wish list group's entity ID and entity type so we can access the group in other functions */
                    WishList.group_entityKeyId   = membershipResult.Groups[i].Group.Id;
                    WishList.group_entityKeyType = membershipResult.Groups[i].Group.Type;

                    PlayFab.DataModels.EntityKey group_ek = new PlayFab.DataModels.EntityKey {
                        Id = membershipResult.Groups[i].Group.Id, Type = membershipResult.Groups[i].Group.Type
                    };
                    GetObjectsRequest getObjectsRequest = new GetObjectsRequest {
                        Entity = group_ek
                    };

                    /*  This is the wish list entity group. To get the wish list CSV, we need to get the object in that entity
                     *  group with the "wishlist" key
                     */

                    PlayFabDataAPI.GetObjects(getObjectsRequest, objectResult => {
                        if (!string.IsNullOrEmpty((string)objectResult.Objects["wishlist"].DataObject))
                        {
                            string wl = (string)objectResult.Objects["wishlist"].DataObject;
                            /* Set up the Unity game store. Specifically, change colors and button text if an item is on the wishlist */
                            StoreSetup.SetUpStore(wl, false);
                        }
                    }, error => { Debug.LogError(error.GenerateErrorReport()); });
                }
            }

            // AddPlayFabIdToGroup(); // Where should this go?


            /* Wish list entity group does not exist, so create one */
            if (!found)
            {
                /*
                 *  Wish list entity groups should follow the following nomenclature:
                 *  [PlayFab title ID] + "wishlist.
                 *
                 *  This nomenclature allows us to find the group by name in the future.
                 */
                string group_name = LoginClass.getPlayerEntityKeyId() + "wishlist";
                CreateWishlist(group_name);
            }
        }, error => { Debug.LogError(error.GenerateErrorReport()); });
    }
Ejemplo n.º 15
0
 /// <summary>
 /// Retrieves objects from an entity's profile.
 /// </summary>
 public static void GetObjects(GetObjectsRequest request, Action <GetObjectsResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
 {
     PlayFabHttp.MakeApiCall("/Object/GetObjects", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Retrieves objects from an entity's profile.
        /// </summary>
        public void GetObjects(GetObjectsRequest request, Action <GetObjectsResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;

            PlayFabHttp.MakeApiCall("/Object/GetObjects", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, apiSettings, this);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Retrieves objects from an entity's profile.
        /// </summary>
        public static async Task <PlayFabResult <GetObjectsResponse> > GetObjectsAsync(GetObjectsRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            if ((request?.AuthenticationContext?.EntityToken ?? PlayFabSettings.staticPlayer.EntityToken) == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call GetEntityToken before calling this method");
            }

            var httpResult = await PlayFabHttp.DoPost("/Object/GetObjects", request, "X-EntityToken", PlayFabSettings.staticPlayer.EntityToken, extraHeaders);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <GetObjectsResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <GetObjectsResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <GetObjectsResponse> {
                Result = result, CustomData = customData
            });
        }