Disable Multiple Logins

Hey all,

I'm trying to make it such that when a user logs in and connects to Photon, any other Photon player sharing the same UID would get disconnected.
Originally, I had planned to get a list from Photon of all active players and call an RPC on them to disconnect them. Unfortunately it appears that Photon doesn't expose a list of all active players in all rooms due to bandwidth limitations.
Another possibility I had considered was building some kind of web backend to keep a Dictionary of all active Photon players. This web backend could then call the older photon player to disconnect in the event of a redundant UID. I'm just not really sure how to handle a server->Unity call, and this seems like a more challenging solution than necessary.

Does anyone have advice for how to restrict multi-logins on Photon? Because this has turned into a massive headache for me :s


  • Hi,

    Something like this implemented on per-room basis with CheckUserOnJoin option set to true when creating the room. New clients with existing name not allowed to join the room.
    But it looks like you need uniqueness for all players in rooms and lobbies.
    Your backend server with Photon Custom Authentication may work, but no way to call Photon client or Photon server from your server. You can only pull your server from clients to check current user status. And of course check this status on connect with Custom Authentication feature.
  • OthelloFella
    edited October 2015
    Thanks for the response, unfortunately I use Photon Cloud and handling a Photon server with Custom Authentication seems like a big leap for me.

    Is there any downside to adding a list of active Photon players to the room's custom properties, such that when a user joins the lobby they iterate through each room's custom properties and if another user has logged on with the same account info the new user sends an RPC to the old user telling them to leave?

    *Edit: Just realized that you can't send RPCs in a lobby. Is there any way to communicate to the room to tell the old login to leave?
  • You do not need to run Photon server. Custom Authentication works with cloud (and designed primarily for cloud). But other server which handles authentication required (your own or 3rd party's).
    Storing user status in room properties may work until racing condition met like 2 clients connecting simultaneously.
    Same for checking user status with FindFriends which I didn't advise for same reason.
    You can't send anything to room from outside of this room via Photon.
    In theory, you can have 2nd connection and handle user uniqueness and signalling between clients in special control room.
  • Mutli auth fix for real time would be tricky. As far as I understand it doesnt use any sessions or anything like that, and looking over the code in photon server shows that after the first login it creates a token which it passes back and forth to allow you in servers. However it never checks to see if the auth stats are in use its self.

    The only way to do this with real time and pun would be to create your auth like documented, and make sure that your script sets a bool or something on the db "isloggedin" from 0 to 1, then every time a player disconnects you would need to use a webrpc call to another script to make it 0.

    This could be dangerous though cause there is a chance a player could get locked out of his account because the server thinks he is already logged in. The auth system of real time is ore or less just met to act as a gateway into your game network. Past that you have to do your own polling.

    Ive spent about 3 days with photon server now, and have gotten most of the auth stuff done. I think another day and it will be completely done. Ill release it to the community once im down.