Check if Peer is returning to lobby from a game server

Options
OliverEberlei
edited February 2013 in Photon Server
Hi everyone,

I've been diving into the Photon Server for the last week and I'm making great progress thanks to your amazing tool.
One question came up however, which I couldn't answer by myself or through your ressources.

I am extending the Loadbalancing Application and I'd like to figure out if a new MasterClientPeer is a new client, or just a client returning to the Lobby from a gameserver. In the latter case I don't want them to go through the login process again and just award them the neccessary rights.

In my case "rights" is just a bool in the MasterClientPeer which determines if the Peer can call Join/Create commands. So for new peers, I'd like this bool to be false by default, and for returning peers it should be true.

Is there a way for the MasterServer to know?

Thanks for your help.

Comments

  • Hi,

    the workflow is like this (a bit abbreviated):
    - client connects to Master (a MasterClientPeer is created, server side)
    - client calls Create / Join on Master
    - client disconnects from Master
    - client connects to GS
    - client calls join / create on GS
    ...

    After the client disconnected from the Master, the MasterClientPeer is disposed on the server-side. When the client is "coming back", it technically establishes a new connection and a new MasterClientPeer object is created. The server-side MasterClientPeer is not aware if it is a "new" client or a "returning" one, there is technically no difference.

    If the MasterClientPeer should recognize that the client is returning from the GS, the client needs to tell him so. (You could generate a kind of "authentication token" that is sent to the client on first login, and which the client passes into each operation on the Master server afterwards - I'm thinking of a kind of "cookie" here).
  • Hey Nicole,

    thanks for your answer. It worked perfectly.
    For anyone interested, here is what I did.

    First, my Server is hooked up to a MySQL Database.

    When a User logs in for the first time, a random 32 character hash is created (I called it the SessionID) and send to the user. The SessionId is also stored in the database.

    The user now pings the server every 45 seconds to refresh the token in the database. (After 1 minute without a ping, the session has timed out)

    When the player joins a game, the game server also pings the master server each 45 seconds and tells him about all the user Ids, which are playing on the game server, so the master server can refresh the sessionId.

    When the player disconnects from the game and rejoins the masterserver, it sends his SessionId and UserId. The Masterserver then checks if this UserId has a running Session with that SessionId and if it exists, it grants the rights. If the session is too old it sends a "SessionTimedOut" message and the user has to login again.


    The added bonus is that I can prevent users from logging in twice ("User already logged in")

    Again, thanks for the pointer Nicole.
  • You're welcome - thanks for sharing your feedback!
  • xzlxt720
    Options
    This sounds need to keep connection with masterserver for ping.