Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How can I ensure that two different clients are not opened at the same time with the Unity Authentic

Discussion in 'Authentication' started by Sequoiea, Jun 29, 2023.

  1. Sequoiea

    Sequoiea

    Joined:
    Apr 3, 2022
    Posts:
    3
    I have a splash screen scene. I do the auth checks on this scene and give the user an id. Using the SignInAnonymusly method. But the player can open the same game once again on the same computer and I don't want that. I want to make a check and if the same player is already in the game on a different client, I want to not be able to connect to the game through the other client he opened.

    Thanks in advance.
     
  2. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    356
  3. Sequoiea

    Sequoiea

    Joined:
    Apr 3, 2022
    Posts:
    3
  4. Evil-Otaku

    Evil-Otaku

    Joined:
    Oct 17, 2012
    Posts:
    79
    You can save the signed-in status in Cloud Save.
     
  5. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,563
    This sounds like a nice idea until you're flooded with support requests / refunds because "It says I'm already logged in, how do I stop that?"

    If your game uses a server, the server can keep a LIVE list of who is already logged in, to prevent the same account from logging in twice concurrently. Saving that list and relying on it will cause the above problem if there's ever a situation (crash, net fail, disconnect, etc.) where the server is offline or the client goes offline without clearing that saved entry.

    Outside that, there is no guaranteed way of avoiding somebody running two instances of the client software. Two instances to two different accounts. Two machines behind the same NAT IP address. Two virtual machines. There's just so many permutations, it's just not possible to guarantee detection of the "bad" behaviour.
     
  6. Sequoiea

    Sequoiea

    Joined:
    Apr 3, 2022
    Posts:
    3
    Greetings again, for those who will think about this situation in the future, I explain how I solved the problem;

    Connect the player to the socket on the custom server on the splash screen. As soon as the socket is connected, make the user online based on the user's id. If a different client tries to connect to the socket with the same user id, the server will send rejection and the other client will leave the game. Even if the player closes the game forcibly via ALT F4 or task manager, since the socket connection will be broken, this information is sent to the server in any way and the server updates the online status of the player by false.

    I hope that has been revealing. Thanks everyone, good work!
     
    passionpuncher and MousePods like this.