PlayFab Samples

Nahuel Beni
SOUTHWORKS
Published in
3 min readOct 13, 2020

At SOUTHWORKS we’re not just Azure devs, we’re also gamers. While doing some “work” we realized that it might be useful to investigate how to bridge the gaps between these powerful Microsoft platforms (and convince our bosses we’re working, not playing). So, in the interest of bringing communities together, SOUTHWORKS has created an open source repository where we (and all you other developers reading this) will post ways to address common scenarios and challenges that call for integrating these two platforms.

Our first contribution to the project is now live and our friends at Microsoft already found it interesting. It is a sample to showcase how to use PlayFab’s Matchmaking service with a simple turn-based multiplayer game (like TicTacToe) as a quick player matching solution. We’ve included a custom implementation of Match Lobbies along with some custom Azure functions and a Cosmos DB to add support for listing, searching and joining a specific match.

Turn-based multiplayer

For this sample we took the Tic-Tac-Toe PlayFab sample and extended it to support two players. To do this we migrated the use of Player Custom Data to use Shared Group Data and tweaked the main loop to support waiting for the second player to move. Additionally, we implemented matchmaking using PlayFab’s Matchmaking service.

Match Lobbies

Finally, we wanted to allow players to join their friends by searching for a specific match lobby. This is a feature not supported out-of-the-box by PlayFab so we had to implement an external solution for storing and searching matches, we used CosmosDB and implemented a flow that looks like this.

Create Lobby

The following diagram briefly describes the flow for creating a new match lobby.

Search Lobby

The following diagram briefly describes the flow of searching a match lobby, as you can see it’s as simple as searching for the available matches in the CosmosDB

Join Lobby

The following diagram briefly describes the flow for joining a match lobby and kicking off the game.

We hope you enjoy and welcome your questions and feedback.

--

--