question

jonathan375735 avatar image
jonathan375735 asked

"CloudScript/ExecuteEntityCloudScript" vs "Client/ExecuteCloudScript"

Hello,

Apart from the minder details what is de difference between the two api calls? For example, in the context of a new (green field) project, which should I use?

I was under the impression that the Entity API was the cool and new future but that seems poorly reflected in the documentation and the typescript definitions (https://github.com/PlayFab/SdkTestingCloudScript/tree/master/Scripts/typings/PlayFab) are even broken for `CloudScript/ExecuteEntityCloudScript`.

Any tips or best practices for a future proof game back-end would be nice.

Best,

Jonathan

CloudScript
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

·
Sarah Zhang avatar image
Sarah Zhang answered

Firstly, for the moment, we would suggest mixed-using Classic API set (Client, Server, Admin) and Entity API set in the project. The Entity API requires an Entity Token in the request header, such as SetObjects, CreateGroup, etc. The Classic API requires a Session Ticket or a Secret Key as thecredentials of accesses, such as GetLeaderboard, SetTitleData, etc. These two types of API sets are independent of each other and each has its uses.

So, just like you need to mixed-use “Classic API” and “Entity API” in a project, you can use both ExecuteCloudScript and ExecuteEntityCloudScript in a new project. ExecuteCloudScript won’t pass the currentEntity to the Cloud Script function, and ExecuteEntityCloudScript will pass it. When you need to call an Entity API in the Cloud Script function, you need to use the ExecuteEntityCloudScript API. When you only want to call a Classic Server API in CloudScript but don’t want to pass the player’s entity to CloudScript, you can call the ExecuteCloudScript.

You can try to separately use ExecuteCloudScript and ExecuteEntityCloudScript to execute the following CloudScript function to check the difference of the CloudScript context.

handlers.checkContext = function (args, context) {
    var context = context;
    return {
        context: context
    };
};

The FunctionResult in ExecuteCloudScript’s response would be something like this.

{
    "context": {
        "playerProfile": null,
        "playStreamEvent": null,
        "triggeredByTask": null
    }
}

And the FunctionResult in ExecuteEntityCloudScript’s response would be like the following one.

{
    "context": {
        "playStreamEvent": null,
        "triggeredByTask": null,
         "currentEntity": {
            "Entity": {
                "Id": "[currentPlayerTitleId]",
                "Type": "title_player_account",
                "TypeString": "title_player_account"
            },
            "EntityChain": "title_player_account!xxx",
            "VersionNumber": 0,
            "DisplayName": null,
            "Permissions": null,
            "Objects": null,
            "Files": null,
            "Statistics": null,
            "Language": null,
            "Lineage": {
                "NamespaceId": "[xxx]",
                "TitleId": "[xxx]",
                "MasterPlayerAccountId": "[xxx]",
                "TitlePlayerAccountId": "[xxx]",
                "CharacterId": null,
                "GroupId": null,
                "CloudRootId": null
            },
            "Created": "2020-06-29T07:30:22.651Z",
            "AvatarUrl": null,
            "LeaderboardMetadata": null,
            "ExperimentVariants": null
        },
        "callingEntityKey": {
            "Id": "[currentPlayerTitleId]",
            "Type": "title_player_account",
            "TypeString": "title_player_account"
        },
        "CustomTags": null
    }
}
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.

jonathan375735 avatar image jonathan375735 commented ·

Thanks for the info. Is it possible to have 'currentEntity' added to the type definitions at (https://github.com/PlayFab/SdkTestingCloudScript/tree/master/Scripts/typings/PlayFab)? This will allow us to better automate our CI pipeline. Which currently requires us to edit the type definition files for the pipeline to succeed.

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.