question

John Peterson avatar image
John Peterson asked

UserData object different between client and server?

Dear PlayFab community,

I'm working with the Unity SDK (C#) and CloudScript (TypeScript).

I'm trying to reconcile some differences between the Player Data object for Unity and CloudScript. I believe that I am up-to-date with both SDKs (typings for TypeScript).

My Unity SDK shows the UserDataRecord as:

    public class UserDataRecord
    {
        /// <summary>
        /// Data stored for the specified user data key.
        /// </summary>
        public string Value;
        /// <summary>
        /// Timestamp for when this data was last updated.
        /// </summary>
        public DateTime LastUpdated;
        /// <summary>
        /// Indicates whether this data can be read by all users (public) or only the user (private). This is used for GetUserData requests being made by one player about another player.
        /// </summary>
        public UserDataPermission? Permission;
    }

And my CloudScript.d.ts shows the corresponding object as:

    /** https://api.playfab.com/Documentation/Server/datatype/PlayFab.Server.Models/PlayFab.Server.Models.GetUserDataResult */
    interface GetUserDataResult {
        /** PlayFab unique identifier of the user whose custom data is being returned. */
        PlayFabId?: string,
        /** 
         * Indicates the current version of the data that has been set. This is
         * incremented with every set call for that type of data (read-only, internal,
         * etc). This version can be provided in Get calls to find updated data.
         */
        DataVersion: number,
        /** User specific data for this title. */
        Data?: { [key: string]: UserDataRecord },
    }

Note that the client has a LastUpdated field, and the server has a DataVersion field. I'm wondering why there is a discrepancy here, and why *both* properties wouldn't potentially be returned to both environments (client and server)?

Thanks for any help anyone can provide!

apisunity3dsdksCloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Joshua Strunk avatar image
Joshua Strunk answered

You are comparing 2 different types. A UserDataRecord GetUserDataResult. Here is the UserDataRecord type in my CloudScript.d.ts file. You can find the same interface in your Cloudscript.d.ts file by using "go to implementation/definition" (F12 in VS & VSCode) with the `UserDataRecord` type on line 12 of your 2nd snippet selected.

https://gist.github.com/JoshuaStrunk/91ad8033b3b471fb96d48fc31a3e963b

Linking gist because trying to put code in AnswerHub posts makes me want to pull my hair out.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

John Peterson avatar image John Peterson commented ·

Bah -- I see that now. Thank you!

And I see, too, that the client has access to that version information at GetPlayerCombinedInfoResultPayload.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.