How do I know if a session already exists on a system? [closed]

3

I have an application where the user can only be logged on to a device at the same time, how can I make this restriction?

I use the Parse.com service, it provides an API for exchanging data between an app and the cloud.

Example: I created my account, I logged in to a device and my login it is saved (in my case I put it in SharedPrefferences in android), every time you open the app you do not need to log in again, that is, type login and password. If the user passes his login and password to third parties, and these third parties try to access from another device I want to say that there is already a session on the X device, and block the third party's access.

The most correct would be to create a table in the webservice where I save the sessions and set something to true, if it is active?

If you have other better ways, thank you.

    
asked by anonymous 10.09.2015 / 22:13

1 answer

0

Create a socket between the client and the server, when the socket disconnects the client is off.

On the client side, just create a socket for communication.

On the server side, wait for new clients to connect, for each connected client to create a thread, within the thread receive messages from the client, depending on the implementation when launching an Exception or a message null means that the client is off.

    
11.09.2015 / 00:16