Sign In Register

How can we help you today?

Start a new topic
Answered

Disconnect(true) logs out the current player

Hey,


We want to prevent players have concurrent logins on multiple devices. Our solution to this was to disconnect all other sessions when a player authenticates. We do this in AuthenticationResponse with the below code at the very end:

  

// Log out all other players signed into this account already
Spark.getPlayer().disconnect(true);

We then listen for the session terminated event and inform the user that their session has ended and to reload the game.


However, we notice that sometimes it logs the current player out. For example, the player who is not logged into their account on any other device, launches the game and authenticates with GameSparks, they then get a session terminated message. 


I believe this happens because the player's previous session timed out after a day but I cannot confirm if that is the case. Is there a solution to this issue?


My only solution I can think of is to not terminate sessions on AuthenticationResponse, but instead wait a short while after authentication has completed and have the client send a message to GS to disconnect other players. I haven't tested this approach, and it's not ideal and it involves more network activity on the client side.


Any thoughts would be appreciated, thanks.


Best Answer

Upon further investigation, it seems sometimes we are mistakenly authenticating the player twice, which would be the cause of this issue. You can safely ignore this post, apologies!

1 Comment

Answer

Upon further investigation, it seems sometimes we are mistakenly authenticating the player twice, which would be the cause of this issue. You can safely ignore this post, apologies!

Login to post a comment