question

brendan avatar image
brendan asked

[Photon][Mobile] Simplify reconnection workflow to gain time

johntube
started a topic on Fri, 11 September 2015 at 6:39 AM

Each time I need to connect a player completely to the game I have to do the following:

  1. Call one of PlayFab's sign in API endpoints

  2. Get CloudScript URL

  3. Get Photon Token

  4. Call RunCloudScript with an initialization action/handler

  5. Set Photon AppVersion from CloudScript (Version & Environment) or (Version & Revision) : this will be useful in the future when versioning with webhooks is available...appversion could be used as URL tag.

  6. Connect to Photon ==> finally the loader animation/spinner is removed, player is on main screen and can play !

I need to simplify this process.
I already implemented the friction free, device signin best practice from LoginPathways sample. I don't know if I should be doing that if application regains focus or unpaused: is foreground again.

Now I need to cache the following:

  • PlayFab's session token
  • CloudScript URL
  • Photon token

The problem is that I'm afraid the 24 hours lifetime of tokens get in the way of things. So I need to save the tokens timestamps and repeat the whole process even if the app is running and foreground with totally transparency to the player.

I'm already struggling with resuming Photon Rooms when the app goes to background when the player is joined to a Room. I don't want to do this even if the app does not go to background !

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

·
brendan avatar image
brendan answered

7 Comments
Brendan Vanous said on Sun, 13 September 2015 at 2:10 PM

Hi Hamza,

I'm not sure I understand the problem. When you start the game, assuming the player logged in at some point in the past, you have the Session Ticket stored locally, as well as the CloudScript URL, and Photon token, as you describe. Why would it be necessary to walk through all the steps you describe, if you're not getting an error when making calls to the service?

Brendan


johntube said on Wed, 16 September 2015 at 4:24 PM

Hi Brendan,

Please correct me if I'm wrong:

  • Why do we need the GetCloudScriptUrl in the first place? This reminds me of all your API methods that accepts TitleId while you have it in the API endpoint URL. I think I will stop calling GetCloudScriptUrl and guess it offline : {titleId}.playfablogic.com/{version}/{env.}/. I will not live long enough to see ".playfabsandbox.com" used anywhere.

  • "if you're not getting an error when making calls to the service": can you please tell me how to avoid this. Don't forget this can happen with one of Photon servers during the many authentication handshakes of the switch between servers. As I said before, I think I need to save a timestamp of the session tokens. When loaded from cache, I need to check their age. What is the maximum age allowed here? 12 hours? Do I need a study of how average players spend playing a game on their smartphone?

  • PlayFab does not cache the session token timestamp, the CloudScript URL neither. Here is what it saves exactly:

Snippet from PlayFabData.cs

public class PlayfabGameData 
{
    public string TitleId;
    public string CatalogVersion;
    public bool KeepSessionKey;
    public bool SkipLogin;
    public string AuthKey;
}

Brendan Vanous said on Wed, 16 September 2015 at 4:58 PM

Hi again,

I'm all for error handling - and looking at your flow, I suppose the only one I was really curious about was the GetCloudScriptUrl call. I was also wondering about the need to get the AppVersion, but I get your point. Basically, you only need to call GetCoudScriptUrl once, generally speaking. You could do that when you start the game, but it'll save you a little time to just cache it. If we ever have to move your scripts to running on a different server (unlikely - and super-rare, even then) it could change, so it's still worth handling the 404 error and calling GetCloudScriptUrl again, if that happens.

Brendan


johntube said on Wed, 16 September 2015 at 5:39 PM

Hi Brendan,

I'm trying hard to make CloudScript webhooks versioning a priority.

Since I can't access my Photon application management dashboard, I can't test the solution I have right now to make webhooks call point to the same CloudScript revision as the normal RunCloudScript calls.

Right now it's hardcoded stuck at "1/prod". What I want to try is setting the base webhooks/webrpc URL to the following:

<titleId>.playfablogic.com/webhooks/{AppVersion}/<securityToken>;

AppVersion is a default URL tag supported by Photon.

If I set my AppVersion to "{version}/{env}" then we could have something working.

Hamza


Brendan Vanous said on Wed, 16 September 2015 at 6:26 PM

Just so you know, it's not actually the version - it's the server number. That's what I meant concerning the possibility of us having to shift titles to different logic servers over time - if that happens, your URL will be different, and we can't guarantee what that number will be. The test titles are all on 1 at the moment.

Brendan


johntube said on Thu, 17 September 2015 at 12:29 PM

Hi Brendan,

I wanted to share with you that my title 2169 is not a test tile and based on what you said, it is running on server 1.

Hamza


Brendan Vanous said on Thu, 17 September 2015 at 6:57 PM

That's fine - quite a few live titles are also running on server 1, as it has quite a lot of capacity. If we see any titles which use Cloud Script starting to take a disproportionate amount of server time (due to having high DAU counts, usually), we may shuffle titles around - and possibly just that one.

Brendan

10 |1200

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

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.