question

Vsevolod Metelskyi avatar image
Vsevolod Metelskyi asked

Is there a way to get an event on the client whenever Inventory or currencies were changed on the PlayFab?

I have removed all the logic that is related to changing inventory items and virtual currencies amounts from the game client and made it so PlayFab could take care of them. But now I don't know what would be the best decision for synchronizing data. For example, I have finished a level, called a CloudScript that would decide what rewards should I receive, my PlayFab account got the rewards and now I should get users inventory and currencies once again to display new values in the game client. I could just call an update script every time I now inventory or currencies were changed but I am not sure that's the best approach.

So my question is: is it possible to somehow subscribe to the server events from the client side and refresh displayed values every time users inventory or currencies were changed? Or is there are any other ways of getting the same result without having manually call the update script every time the game logic assumes inventory or currencies could have been changed?

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

[Edit: Please note that the PubSub feature is on hold at this time, and so the preview is not available. For developers needing a PubSub-like solution, we recommend having a look at this sample, which shows how to use SignalR for this: PlayFab-Samples/Samples/CSharp/MessagingClient at master PlayFab/PlayFab-Samples (github.com)].

Subscribe to the server events is possible. I believe you are requesting for our new feature PubSub, which is still in Private Preview. Please see the document on our website: https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/pubsub/ and feel free to search it for tutorials and documents. Be aware that private preview feature can only be accessed by Pro or Enterprise Tier user.

The work around solution is to configuring a Rule, which will be triggered by corresponding event, to send push notification to the player.

Back to your scenario, after the player actively calls the Cloud Script and get a response, the VC/items changes should be done. You can directly update/sync the local data from PlayFab server. Why would you need to subscribe this? I thought it will only be needed when the users are unaware of the data changing.

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.

darren zou avatar image darren zou commented ·

I think its for When another player accepts a trade it should notify the other player in real time

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.