Forum QuickConnect Check if player has already logged in

Discussion and help relating to PlayerIO's QuickConnect feature, including Facebook Connect and Kongregate Connect.

Check if player has already logged in

Postby FefanSoftware » September 27th, 2012, 5:42 am

Couldn't find it anywhere in the documentation, but how would I check whether a player has already logged in using QuickConnect? I have multiple rooms so 1 player might be in 1 room and the other in another room so I cannot check in the server code. I want to check when the player tries to login. Thanks (:
FefanSoftware
 
Posts: 26
Joined: August 28th, 2012, 4:30 pm

Re: Check if player has already logged in

Postby Benjaminsen » September 27th, 2012, 10:58 am

FefanSoftware wrote:Couldn't find it anywhere in the documentation, but how would I check whether a player has already logged in using QuickConnect? I have multiple rooms so 1 player might be in 1 room and the other in another room so I cannot check in the server code. I want to check when the player tries to login. Thanks (:


There is nothing inherent in the platform preventing users from connecting to the multiplayer server twice. The short story of why this is so, is that we distribute your game code over multiple servers, thus your users could be connected to servers in different data centers.

However you can solve this yourself, by storing the current room a user is connected to in BigDB, then frequently reading said BigDB object. If the room the user is connected to is different then what is stored in BigDB, the user is trying to cheat.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Check if player has already logged in

Postby FefanSoftware » September 27th, 2012, 11:37 am

That's a good idea, thank you! :D
FefanSoftware
 
Posts: 26
Joined: August 28th, 2012, 4:30 pm

Re: Check if player has already logged in

Postby FefanSoftware » September 28th, 2012, 10:26 am

I have found a problem however. Currently, I'm simply saving a true/false boolean to the BigDB on the player on join and on leave. The problem is that if the server shuts down while the players are online, the bigDB never turns the online boolean to false. So the next time they log in, they won't be able to because the server still thinks their already online.\
Anything I can do to get around this?
FefanSoftware
 
Posts: 26
Joined: August 28th, 2012, 4:30 pm

Re: Check if player has already logged in

Postby Benjaminsen » September 28th, 2012, 10:37 am

FefanSoftware wrote:I have found a problem however. Currently, I'm simply saving a true/false boolean to the BigDB on the player on join and on leave. The problem is that if the server shuts down while the players are online, the bigDB never turns the online boolean to false. So the next time they log in, they won't be able to because the server still thinks their already online.\
Anything I can do to get around this?


Ah, the proper solution is not to prevent the user to login again, but rather kicking the user already connected.
E.g. you allow the new session and kick the previous when an overlap is detected (preferable without saving user data).

Another method is to use optimistic locks or full overwrite when saving player object, thus saving userdata will either result in a overwrite or fail. This will in many cases remove all advantages of being logged in twice.

Lastly but not least, I personally have a separated service room which I connect all users to on authentication. This allows me to do secure actions when players are not connected to a multiplayer session. In this system I always connect users to a room with their connectUserId as the room id. Using such a system the same user will always connect to the same room, making dual login restriction trivial.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Check if player has already logged in

Postby FefanSoftware » September 28th, 2012, 6:47 pm

I really like the last idea. Simple and genius. Is it okay to have 2 connections though?
FefanSoftware
 
Posts: 26
Joined: August 28th, 2012, 4:30 pm

Re: Check if player has already logged in

Postby Benjaminsen » September 28th, 2012, 7:00 pm

FefanSoftware wrote:I really like the last idea. Simple and genius. Is it okay to have 2 connections though?


Yep you can be connected to as many rooms as you feel like :)
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Check if player has already logged in

Postby FefanSoftware » October 2nd, 2012, 6:01 am

I think I found a flaw with the second connection. What if the "hacker" decides to disconnect the second connection or just never connect to it and instead just connects to the actual game server? He'll be able to log in as the same user and the other user will never know. Any solutions? I can't think of any :I
FefanSoftware
 
Posts: 26
Joined: August 28th, 2012, 4:30 pm

Re: Check if player has already logged in

Postby FefanSoftware » October 20th, 2012, 3:57 am

I never got a reply from this, wondering if anyone can still give me one because I'm still having trouble with it. :D
What if a hacker decides to disconnect the global connection that handles things such as disconnecting him/her for various reasons, global chat and things like that? Then he would be invulnerable.
FefanSoftware
 
Posts: 26
Joined: August 28th, 2012, 4:30 pm

Re: Check if player has already logged in

Postby Benjaminsen » October 22nd, 2012, 1:13 pm

You are absolutely right, there is a flaw in the method. However, there is not really much you can do about it as the system does not provide a single guaranteed shared state.

The best you can do, is to frequently reload BigDB in a room to determine if he is logged in twice.

Likewise, if you toggle full overwrite on BigDB objects when saving state any value a user might gain by dual playing will be instantly lost as it's a single data point.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to QuickConnect