question

Spektra Games avatar image
Spektra Games asked

Actions Triggered by Rules are Running with Delay

I'm triggering an azure function every time an item is grant to the user as using Rules. If item that granted to user is have specific class, than I am granting a another item to user in that azure function. Everything is working fine on PlayFab side but seems like the azure function triggering late. I want to elaborate the problem with an example:

I have two catalog item in primary catalog.

1=> A_Strong_Car (Item class: Car)

2=> Wheel_Tier_2 (Item class: CarWheel)


If an user purchase A_Strong_Car item, then I need grant Wheel_Tier_2 item to this user as free price.

I have I rule for listening grant items. The name of this rule is OnItemGranted and this rule is triggering by com.playfab.player_inventory_item_added event. This rule is executing a azure function when triggered. The name of executing azure function is OnItemGranted. In this azure function, I am checking the class of item that granted. If the class of item is Car, then I am grant Wheel_Tier_2 item to user with custom data as using serverApi.GrantItemsToUsers api.

The Wheel_Tier_2 item is successfly granting to user but the user is not see this second item in his inventory when user refresh the inventory rgiht after the PlayFabClientAPI.PurchaseItem api resulted as successful.

After the PlayFabClientAPI.PurchaseItem api resulted as successful; if the user does not wait and immediately call PlayFabClientAPI.GetUserInventory for refreshing the inventory, then user will not see Wheel_Tier_2 in his inventory.

But If user wait for a little bit(Like a 1 second) after PlayFabClientAPI.PurchaseItem api resulted as successful and then call PlayFabClientAPI.GetUserInventory for refreshing the inventory, then user will see Wheel_Tier_2 in his inventory.

I don't want the user to wait for the com.playfab.player_inventory_item_added event. I think the event should be trigger synchronous with time to grant item to user, not asynchronous. The action(Mean OnItemGranted azure function in this case) that connected to rule must have finished his work(process of azure function) already if PlayFabClientAPI.PurchaseItem api resulted as successful.

PlayStream
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

·
Seth Du avatar image
Seth Du answered

1 second is common and due to the nature of Restful API, PlayFab cannot guarantee all actions are real-time. There are many factors that may cause the delay, but if Wheel_Tier_2 is supposed to grant to the player for free, you can add both items in a bundle or a container.

10 |1200

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

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.