question

purchase avatar image
purchase asked

How can I send a turn update event to the other player in that match through an Azure Function?

I am making a Tic Tac Toe multiplayer game, and as soon as I make a move, I am calling an Azure Function to validate the move. I have some confusion regarding the turn update of this match. How can I send a turn update event to the other player in that match through an Azure Function? Is it possible to do? I haven't found examples regarding this. If it's possible, could you guide me on how to achieve it?,

multiplayer
10 |1200

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

JayZuo avatar image
JayZuo answered

There are multiple ways to implement this and SOUTHWORKS provides two samples:

  1. https://github.com/southworks/playfab-samples/tree/master/multiplayer-tic-tac-toe

  2. https://github.com/southworks/playfab-samples/tree/master/p2p-tic-tac-toe

You can either use Shared Group Data or PlayFab Party to notify the turn update. Personally, I'd recommend using PlayFab Party as with this way, there will be no need to poll the game state.

10 |1200

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

Xiao Zha avatar image
Xiao Zha answered

It seems you want to implement a turn-based game, you could use Shared Group Data with AzureFunction to do that. You may refer to Using Shared Group Data - PlayFab | Microsoft Learn. As for “send turn update event to other player”, PlayFab doesn’t provide such feature for you to inform other player of next turn. For how players know which player's turn it is, you could store the player of the current turn in Shared Group Data and update this data in the cloud script after each turn, and then let the client poll the shared group data to know whose turn it is.

2 comments
10 |1200

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

purchase avatar image purchase commented ·

On each frame, the client needs to check the shared group data to see if their turn has been updated ?

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha purchase commented ·

Since the Get Shared Group Data API has a rate limit of 200 calls per 2 minutes, you may check the shared group data based on this rate limit.

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.