Code Monkey home page Code Monkey logo

playfabmatchhistoryextension's Introduction

PlayFabMatchHistoryExtension

The goal of this Project is to showcase how Azure PlayFab can be extended by a scaleable Match History with Azure. We wanted to make sure to integrate with Azure PlayFab as much as possible to feed into the built-in PlayFab Analytics solution.

We only implemented a limited set of queryable statistics, as every game has its very own stats that are interesting to them. Our reference implementation should cover most of these use cases.

This extension is intended as a Proof of Concept and not intended for production use.

Prerequisites

Development Prerequisites

Deploying

PlayFab

  • Get your Title ID (from the Game Studio dashboard or from the GameManager)
  • Get a developer secret key: Create Developer Secret Key
  • Copy it to later use it in an environment variable or as parameter to Terraform

Terraform

You can either choose to set the PlayFab Title Id and Developer Secret as environment variables (recommended, see below), or you can choose not to do so, and instead provide the secret when calling terraform plan or terraform apply, respectively.

Environment Variables

These are optional, but if you do not set them, you will be prompted by Terraform for their values.

Name Description
TF_VAR_pf_title_id A PlayFab Title ID to authenticate against
TF_VAR_pf_developer_secret A PlayFab Developer Secret for the above Title

Init Terraform:

Before initializing, set up a copy of example.backend.config.tf, and configure an existing storage account and container to be used for Terraform state management.

Then, init:

terraform init -backend-config='.\config\backend.local.config.tf'

Apply

terraform apply

Architecture

Architecture Diagram

We use custom PlayFab Player events that are generated by the "GameServerMock" project which is simulating a game server that submits match finished events for Players that participated in the session.

This means that we are expecting the game server to publish one "player_finished_match" event for every player that attended at the end of a match.

We are aware, that integrating this into a C++ / UE / Unity server will require outbound HTTPS connection towards PlayFab. We used the PlayFabSDK but you could build a optimized versions of the web requests that we used.

Getting Events into Azure

The next step is to register a Queue triggered Azure function that takes our custom event and writes it into our Data store. We decided to use CosmosDb as the serverless SKU enables simple testing and scale abilty. As partition key we are using the PlayFab Master Player Id, which gives every Player their own partition. When looking for the History of a Player this partition schema makes sense and enables us to scale. Be aware that this might need optimization for high throughput players that are attracting more than ~20k history request a second.

Deliver the Data to the client

The PublicAPI function project is used to authenticate every request to make sure that only authenticated PlayFab users can query it. Now we only need to query our CosmosDb for the match data of a player and return it.

Have a look at the Swagger UI by navigating to the deployed function app and using the api/swagger/ui endpoint, e.g.

https://pfmatchhistory-publicapi-function.azurewebsites.net/api/swagger/ui

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.