PlayFab Integration

Introduction

In this document we help you integrate PlayFab with Photon. With this approach, both systems will get used in parallel to their full potential. Billing is separate for each service. At PlayFab, please find Photon in the Add-ons - Multiplayer section of your title. PlayFab's Photon add-on allows you to set up one or two Photon applications (one Photon Realtime and/or one Photon Chat application). Read on for setup instructions for Photon.

Custom Authentication

Dashboard Configuration

Here are the steps to setup custom authentication with PlayFab:

  1. Go to Photon dashbaord.
  2. Choose an application or create a new one.
  3. Click "Manage".
  4. Under "Authentication" section, click "Custom Server".
  5. [Required] Set Authentication URL to https://{PlayFabTitleId}.playfabapi.com/photon/authenticate. Make sure to replace {PlayFabTitleId} placeholder with your actual PlayFab TitleId.
  6. Save by hitting "Create".
  7. [Recommended] Untick "Allow anonymous clients to connect, independently of configured providers".

Client Code

Client is expected to send a pair of key/values as credentials:

  1. [Optional] Configure "IsPersistent", "HasErrorInfo" and "AsyncJoin". Remove their keys if you want to keep default values.

Notes

  • "CustomHttpHeaders" setting is not supported as those are not exposed in the CloudScript handlers. Any value you set will not be useful.
  • PlayFab suggests the following names for Realtime Webhooks CloudScript handlers functions:

    • "PathCreate": "RoomCreated"
    • "PathClose": "RoomClosed"
    • "PathJoin": "RoomJoined"
    • "PathLeave": "RoomLeft"
    • "PathEvent": "RoomEventRaised"
    • "PathGameProperties": "RoomPropertyUpdated"

    However, you are free to choose whatever name you want.

  • All Photon Realtime Webhooks except "PathClose" and all WebRPCs should set PlayFab's CloudScript global variable "currentPlayerId" to the value of the "UserId" argument.
  • Configured Realtime Webhooks or WebRPCs called by client will not work unless there is an explicit CloudScript handler with the same name.

    Examples: If you configured "PathJoin" to "GameJoined", you need to have this function in the target CloudScript revision:

        handlers.GameJoined = function(args)
    {
        // your custom code goes here
        return { ResultCode : 0, Message: "Success" }; 
    };

    If client calls "foo" WebRPC method, you need to have this function in the target CloudScript revision:

        handlers.foo = function(args) 
    {
        // your custom code goes here
        return { ResultCode : 0, Message: "Success" }; 
    };

    {% endif %}

 To Document Top