How do I verify if someone is connected or not

Get help using Construct 2

Post » Mon Jun 15, 2015 10:18 am

Hello,

I'm working in a game where the players have to loggin and they connect through ajax/PHP to a MySQL database, and then they get all the game stats. My problem is that in this very moment I can't avoid that 2 (or more) people connect to the same player account, so I want to verify if someone is allready connected to avoid to make simmultaneous connections.

I thought to put a value in the database table called "connected" as token, so then, when the player is connected I changed the value to 1 (or true) but I don't know how to change it to 0 (or false) when the player loggout or close the navigator, so it keeps allways "connected".... My server is a normal web server (for the moment), so I can't install any application...

Any ideas?

thanks for your help.
B
21
S
3
Posts: 77
Reputation: 1,112

Post » Tue Jun 16, 2015 10:28 am

Anybody have a suggestion?
B
21
S
3
Posts: 77
Reputation: 1,112

Post » Tue Jun 16, 2015 10:41 am

It sounds more like an issue on server side where you should handle something like a timeout for a connection.
If the account hasn't been accessed for X time, then pass the account to "not connected".

To be honest, this is out of the scope of C2 as, as mentioned, this is more server side.

On C2's end, as the tab/browser is closed there is no way to handle this behavior.
If the player does voluntary logout from a "logout" button in your game though, you should be able to handle this through AJAX.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Tue Jun 16, 2015 11:08 am

Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303

Post » Tue Jun 16, 2015 11:17 am

Last edited by Odin on Tue Jun 16, 2015 11:23 am, edited 1 time in total.
B
21
S
3
Posts: 77
Reputation: 1,112

Post » Tue Jun 16, 2015 11:28 am

That is perfect for you:

http://www.sitepoint.com/users-php-sessions-mysql/

Part two is control access. If this not help, better ask in a php forum.
I work with SmartFox, all learned by myself with google and testing.
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303

Post » Tue Jun 16, 2015 11:44 am

deathangel1479 wrote:That is perfect for you:

http://www.sitepoint.com/users-php-sessions-mysql/

Part two is control access. If this not help, better ask in a php forum.
I work with SmartFox, all learned by myself with google and testing.


I'm not a expert with mysql sentences but I think I can do this.

Thanks.
B
21
S
3
Posts: 77
Reputation: 1,112


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 22 guests