Search Unity

Third Party Login system with PUN

Discussion in 'Multiplayer' started by hodispk, Sep 3, 2015.

  1. hodispk

    hodispk

    Joined:
    Jun 16, 2015
    Posts:
    19
    Hi all, and @tobiass :)

    Like the title say's i try to make a login system with Photon's friends PlayFab, but since PlayFab it's a web-based API they don't have any method to check if the player is already logged in.
    My question is can I do it with Photon? So when a player it's already logged in and i try to loggin on his account I will receive a message like "Player already in game" or the player which is already logged in to have his connection dropped.

    I use PlayFab username/password, currency, etc.


    Off-topic: i would like to know PlayFab representant on unity forum too :) if he see this.

    Thx
    hodispk
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    Photon does not have a session for users. Actually, it leaves anything related to "user check" to the custom authentication service and just uses that data.
    You could make up a session id on the device. The clients can ping PlayFab regularly (every 5 sec, e.g.) to tell it the session is still alive. In authenticate, you send the session along with the userId. With that, the server can check "is this user known" and "if this user had a session in the last 5 seconds, is this the same client sending me an authenticate?!". So you could modify the process to reject new sessions, if one exists.
     
  3. hodispk

    hodispk

    Joined:
    Jun 16, 2015
    Posts:
    19
    Thank you, it's an interesting idea, but a bit overwhelming for me.
    I don't know if PlayFab have any method like that (ping) or must i build it on my own. If you know smthing or can u link me an article with smthing like that i would be greatful.

    Again this is a good answer(as expected), thank you @tobiass
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    I am also not sure if PlayFab has this.
    I hoped someone might jump onto this topic but maybe you just ask them directly (in the PlayFab forum), if this is supported or how to implement this.
     
  5. JohnTube

    JohnTube

    Joined:
    Sep 29, 2014
    Posts:
    66
    @Brendan Vanous @PlayFabJames

    PlayFab can't do this out-of-box...They have a session per user (token lasts 24hours), so technically we could know last login timestamp but there is no explicit logout API method/endpoint so you can't tell for sure if user is still connected from elsewhere!

    If this is a must, what Tobias mentioned above is the way to go:
    periodic ping to server using PlayFab's CloudScript and a "key/value flag" per user in UserData or TitleData...

    There is a feature request here.
    Same topic on PlayFab forums here.
     
  6. Brendan-Vanous

    Brendan-Vanous

    Joined:
    Nov 7, 2014
    Posts:
    73
    Yes, as @JohnTube pointed out, we (@hodispk and PlayFab) had a good conversation about this in our support forum. In short, yes, we (PlayFab) provide a Session Ticket when the player signs in. Any call to our service using that ticket will get an expiration error once its lifetime has elapsed (currently 24 hours). For checking whether there has been another sign-in by the same player, the information on the last login time is returned with the account info (https://api.playfab.com/Documentation/Client/method/GetAccountInfo), so you can store your login time (retrieved right after login), then check periodically to make sure it hasn't changed (indicating that the account signed in on another device).

    Brendan
     
    JohnTube likes this.
  7. VengenceARTs

    VengenceARTs

    Joined:
    Apr 2, 2016
    Posts:
    6
    is theres any support for a photon pun log in system?
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    There is no plugin as such but you can combine Photon clients with any community backend or auth service you want. PlayFab, Steam, Oculus, etc are possible.
    You can also build your own, Custom Authentication service.